System permissions on Android
When a flow runs the Request permission action, the Adapty SDK passes the permission request to your app. Your code shows the system dialog and passes the result to the flow. Follow this reference to write the Android code that passes the result of each permission request to the flow. For each permission that the action can request, this page describes:
- What users see.
- What your app declares, and how it requests the permission.
- The responses that Android can give to each permission request.
- How your app passes each response to the flow, as a result and its argument.
In a cross-platform app, your code also requests each permission on iOS.
Set up the permission handler
Main article: Handle permission requests in flows
Before you follow this reference, set up a permission handler: the code in your app that receives each permission request and passes the result back. This page only covers what to request and which result to pass for each permission.
Add the request to a flow
Main article: Request permissions in a flow
To ask users for a system permission, in the Flow & Paywall Builder, add the Request permission action to a screen of your flow.
How to pass the result
Return the result
Call the callback parameter of the onShowRequestPermission method with true or false, followed by the argument from the table of the permission. For example, this camera function passes the result of a camera request to the flow: granted, declined in the dialog, declined before the request, or unsupported on a device without a camera.
import android.Manifest
import android.content.pm.PackageManager
import com.adapty.ui.listeners.AdaptyFlowEventListener.PermissionCallback
fun requestCamera(requester: RuntimePermissionRequester, callback: PermissionCallback) {
if (!requester.activity.packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)) {
return callback(false, "unsupported")
}
requester.requestAll(arrayOf(Manifest.permission.CAMERA), callback)
}If your app uses a cross-platform SDK React Native, Flutter, Unity, Kotlin Multiplatform, or Capacitor , pass the same values with the call that its guide shows.
Prepare the listener for each system response
For each permission, Android reports one of several permission states. The table in each permission section lists every state, and the result that your listener passes for it. Your code for a permission needs to cover each row. For example, the camera function above passes unsupported for a device without a camera, and the RuntimePermissionRequester class covers the other rows of the camera table.
What the flow does with the result
After your app passes the result, the flow runs the After response actions. The default action is Navigate Next, so users go to the next screen whether they grant the permission or decline it. Without an After response action, users stay on the screen.
To send users who grant the permission and users who decline it to different screens, add actions to When allowed and When denied. The flow then runs these actions instead of the After response actions:
- When allowed actions: After the user grants the permission.
- When denied actions: After your app passes
denied,restricted, orpermanently_deniedto the flow.
If the only When allowed or When denied action is Do nothing, the flow moves on to the After response actions. To keep users who decline on the screen, remove every action from After response. Users who grant the permission then need their own way forward: add Navigate Next to When allowed.
Pass the argument (in React Native and Capacitor, the detail property) that matches the result:
- For a granted result:
granted. Uselimitedif the user granted part of the access, such as a selection of photos. Useprovisionalfor provisional authorization, which iOS grants in two cases:- Push notifications: If your app requests provisional authorization, iOS grants it without asking the user. The notifications then arrive quietly, in the Notification Center only, until the user decides to keep them or turn them off.
- Location always: iOS asks for Always access in two alerts. Allow While Using App in the first alert grants Always access until the second alert. iOS shows the second alert when the app first needs location in the background. In it, the user selects Keep Only While Using or Change to Always Allow.
- For a not-granted result:
denied. Userestrictedif a device policy, such as parental controls, blocks the permission. Usepermanently_deniedif the system no longer shows the dialog to the user. - For a permission your app doesn’t request:
unsupported, with a not-granted result and no dialog. - When the user made no choice: No argument. For example, the user closed the dialog, or the OS reported no decision before the timeout in your code. The flow then runs the After response actions.
Pass the arguments in lowercase, exactly as written. For a not-granted result with any other argument, such as Denied or an error message, the flow runs the After response actions.
Rules for every permission
-
Tell a new refusal from an earlier refusal: A not-granted result can mean that the user declined in the dialog, that Android showed no dialog after an earlier refusal, or that the user closed the dialog without making a choice. The first two cases run the When denied actions, and your analytics tell them apart. The third case passes no argument, so the flow runs the After response actions. Android doesn’t report whether it showed the dialog. To find out, call the
shouldShowRequestPermissionRationale()method before and after the request. Store atrueorfalsevalue for each permission: whether your app requested it before. The method returnsfalsebefore the first request, after Android stops showing the dialog, and after the user closes the dialog without making a choice. When the permission isn’t granted after the request, pass this argument:What happened shouldShowRequestPermissionRationale()The app requested the permission before Argument The user declined in the dialog truebefore or after the requestAny deniedAndroid showed no dialog after an earlier refusal falsebefore and after the requestYes permanently_deniedThe user closed the first dialog without making a choice falsebefore and after the requestNo No argument After your app requested a permission once, Android sends the same response in two cases: the user closes the dialog without making a choice, or Android declines the request without showing the dialog. In both cases, the permission isn’t granted, and the
shouldShowRequestPermissionRationale()method returnsfalsebefore and after the request. Android doesn’t report whether it showed the dialog, so no code can tell these cases apart. Your app passespermanently_deniedfor both, and the flow runs the When denied actions. For example, the first case happens when Android shows the dialog again after an Only this time grant expires. -
Request from the
Activityon screen: AnActivityis the Android component that shows a screen of your app. While the flow is shown, request the permission from theActivitythat is on screen: Android delivers the user’s choice only to a resumedActivity. When the flow has its ownActivity, a request from theActivitybehind it returns the user’s choice only after the flow closes. A flow has its ownActivitywhen the Flutter SDK shows it with thepresent()method, and when the Kotlin Multiplatform or Unity SDK shows it. Native Android views, the Capacitor SDK, and React Native SDK 4.3.0 and later show the flow in theActivityof your app. -
Don’t reuse an earlier result: Some grants expire. Only this time lasts while the app is in use. For apps that target Android 11 or higher, Android resets the permissions of an app that the user hasn’t used for a few months. Don’t store a result for a later request.
-
Reset the user’s decisions when you test: To see a dialog again, delete the app, or clear its data with the
adb shell pm clear <package>command. Clearing the data also resets the saved values. Theadb shell pm revokeandpm clear-permission-flagscommands only reset the permission: its saved value staystrue. Don’t install the test build with theadb install -gcommand: it grants every runtime permission, so no dialog appears.
Notifications
Push notifications
- What the user sees: On Android 13 and later, a dialog with Allow and Don’t allow. The user can also swipe the dialog away, which leaves the permission unchanged. Android 12 and earlier show no dialog: notifications are on unless the user turns them off in the system settings.
- Setup: Add the
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />element toAndroidManifest.xml. On Android 13 (API 33) and later,POST_NOTIFICATIONSis a runtime permission. Only apps that target API 33 or higher decide when the dialog appears. After an app that targets API 32 or lower creates its first notification channel, Android shows the dialog when the app starts anActivity. After one Don’t allow, Android doesn’t show it to such an app again until the app is reinstalled. On Android 12 and earlier, show no dialog: call theNotificationManagerCompat.areNotificationsEnabled()method, which returns whether notifications are on.
Pass the result that matches the notification permission state:
| What Android reports | Result to pass |
|---|---|
| Granted | Granted, granted |
| Denied in the dialog | Not granted, denied |
| Denied, and Android showed no dialog | Not granted, permanently_denied |
| The user swiped the dialog away on the first request | Not granted, no argument |
| On Android 12 and earlier, notifications are on | Granted, granted |
| On Android 12 and earlier, notifications are off | Not granted, permanently_denied |
- Limitations: On Android 13 and later, the user can block notifications for the app in the settings while the
POST_NOTIFICATIONSpermission stays granted. TheareNotificationsEnabled()method then returnsfalse. If the flow needs visible notifications, call theareNotificationsEnabled()method too. When it returnsfalse, pass a not-granted result.
Location
Location while using the app
- What the user sees: On Android 12 and later, a dialog where the user selects Precise or Approximate location. The dialog has the buttons While using the app, Only this time, and Don’t allow. If the app only requests the
ACCESS_COARSE_LOCATIONpermission, the user can only grant approximate location. - Setup: Declare the
ACCESS_COARSE_LOCATIONpermission inAndroidManifest.xml. To request precise location, declare theACCESS_FINE_LOCATIONpermission too. Request both permissions together: some Android 12 releases ignore a request for theACCESS_FINE_LOCATIONpermission alone.
Pass the result that matches the location permission state:
| What Android reports | Result to pass |
|---|---|
| Precise or approximate location granted | Granted, granted |
| Denied in the dialog | Not granted, denied |
| Denied, and Android showed no dialog | Not granted, permanently_denied |
To report approximate location in analytics, pass limited with the granted result instead of granted. The flow still runs the When allowed actions.
- Limitations:
- Only this time grants access while the app is in use.
- When the user changes precise location to approximate, in the dialog or in the Android settings, Android restarts the app process.
Location always
- What the user sees: Two steps.
- Android 10: The dialog includes Allow all the time.
- Android 11 and later: For apps that target Android 11 or higher, the dialog has no Allow all the time option. The user turns on background location on a settings page.
- Setup: Declare the
ACCESS_COARSE_LOCATIONandACCESS_FINE_LOCATIONpermissions inAndroidManifest.xml. For Android 10 (API 29) and later, declare theACCESS_BACKGROUND_LOCATIONpermission too. Android 9 and earlier grant background location together with foreground location. Request foreground location first, then background location in a separate request. For apps that target Android 11 or higher, a request for foreground and background location together grants neither. Google Play restricts background location to an app’s core features.
Pass the result that matches the location permission state:
| What Android reports | Result to pass |
|---|---|
| Foreground location not granted in its request | As for Location while using the app: denied, permanently_denied, or no argument |
| Background location granted | Granted, granted |
| Background location not granted when the user comes back, or Android showed no settings page | Not granted, denied |
| On Android 9 and earlier, foreground location granted | Granted, granted |
- How to pass the result: On Android 11 and later, the user leaves the app for the settings page. When the user comes back to the app, read the permission state and pass the result.
Precise location
- What the user sees: On Android 12 and later, if the user selected Approximate in the location dialog, Android shows a second dialog when your app requests precise location. In this dialog, the user can switch to precise location, either whenever the app is in use or for this session only (Only this time), or keep approximate location. If approximate access lasts only for this session, the user can switch to precise location for this session only, or keep approximate location. On Android 11 and earlier, the user can’t select approximate location: an app that requests the
ACCESS_FINE_LOCATIONpermission receives precise location. - Setup: Declare the
ACCESS_COARSE_LOCATIONandACCESS_FINE_LOCATIONpermissions inAndroidManifest.xml. When only approximate location is granted, request both permissions again.
Pass the result that matches the location accuracy:
| What Android reports | Result to pass |
|---|---|
ACCESS_FINE_LOCATION granted, including Only this time | Granted, granted |
Only ACCESS_COARSE_LOCATION granted after the request | Not granted, denied |
| No location access, denied in the dialog | Not granted, denied |
| No location access, and Android showed no dialog | Not granted, permanently_denied |
On Android 11 and earlier, ACCESS_FINE_LOCATION granted | Granted, granted |
Camera and media
Camera
- What the user sees: On Android 11 and later, a dialog with While using the app, Only this time, and Don’t allow.
- Setup: Declare the
CAMERAruntime permission inAndroidManifest.xml. TheCAMERApermission implies the required featuresandroid.hardware.cameraandandroid.hardware.camera.autofocus, so Google Play doesn’t offer the app to devices without a back camera. To install the app on such devices, declare the<uses-feature android:name="android.hardware.camera" android:required="false" />element.
Pass the result that matches the camera permission state:
| What Android reports | Result to pass |
|---|---|
| Granted, including Only this time | Granted, granted |
| Denied in the dialog | Not granted, denied |
| Denied, and Android showed no dialog | Not granted, permanently_denied |
The device has no camera: FEATURE_CAMERA_ANY is missing | Not granted, unsupported |
- Limitations: Shortly after the app goes to the background, an Only this time grant expires.
Microphone
- What the user sees: On Android 11 and later, a dialog with While using the app, Only this time, and Don’t allow.
- Setup: Declare the
RECORD_AUDIOruntime permission inAndroidManifest.xml.
Pass the result that matches the microphone permission state:
| What Android reports | Result to pass |
|---|---|
| Granted, including Only this time | Granted, granted |
| Denied in the dialog | Not granted, denied |
| Denied, and Android showed no dialog | Not granted, permanently_denied |
- Limitations: Microphone and Speech recognition use the same permission,
RECORD_AUDIO. After the user grants one of them, or Android stops showing its dialog, a request for the other one returns the same permission state without a dialog.
Photos
- What the user sees: On Android 14 and later, a dialog where the user selects limited access, full access, or no access. Limited access opens a system picker where the user selects photos and videos. On Android 13, the dialog has no option for limited access.
- Setup: On Android 13 and later, request the
READ_MEDIA_IMAGESandREAD_MEDIA_VIDEOpermissions together. On Android 14 and later, add theREAD_MEDIA_VISUAL_USER_SELECTEDpermission to this request. On Android 12 and earlier, request theREAD_EXTERNAL_STORAGEpermission. Declare all four permissions inAndroidManifest.xml:
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />Pass the result that matches the photo and video permission states:
| What Android reports | Result to pass |
|---|---|
On Android 13 and later, READ_MEDIA_IMAGES or READ_MEDIA_VIDEO granted | Granted, granted |
On Android 14 and later, only READ_MEDIA_VISUAL_USER_SELECTED granted | Granted, limited |
On Android 12 and earlier, READ_EXTERNAL_STORAGE granted | Granted, granted |
| Nothing granted, denied in the dialog | Not granted, denied |
| Nothing granted, and Android showed no dialog | Not granted, permanently_denied |
- Limitations:
- Google Play restricts the
READ_MEDIA_IMAGESandREAD_MEDIA_VIDEOpermissions to use cases in its policy. Other apps use the Android photo picker, which needs no permission. - To report a partial grant on Android 14, declare the
READ_MEDIA_VISUAL_USER_SELECTEDpermission. In an app that targets Android 14 or higher and doesn’t declare this permission, Android reports theREAD_MEDIA_IMAGESandREAD_MEDIA_VIDEOpermissions as granted after the user selects some photos. After the app goes to the background, Android eventually revokes that grant. Your app then passesgrantedfor access to a selection only. - Access to the selected media on Android 14 expires eventually.
- Google Play restricts the
Media library
- What the user sees: A runtime permission dialog.
- Setup: For Android 13 and later, declare the
READ_MEDIA_AUDIOpermission inAndroidManifest.xml. For Android 12 and earlier, declare theREAD_EXTERNAL_STORAGEpermission with theandroid:maxSdkVersion="32"attribute.
Pass the result that matches the audio permission state:
| What Android reports | Result to pass |
|---|---|
| Granted | Granted, granted |
| Denied in the dialog | Not granted, denied |
| Denied, and Android showed no dialog | Not granted, permanently_denied |
- Limitations: Android has no partial access to audio files: the
READ_MEDIA_VISUAL_USER_SELECTEDpermission only covers photos and videos.
Speech recognition
- What the user sees: The microphone dialog: Android has no separate speech recognition permission.
- Setup: Declare the
RECORD_AUDIOpermission inAndroidManifest.xml. TheSpeechRecognizerclass needs no other permission. If the app targets Android 11 (API 30) or higher, add a<queries>element for the speech recognition service:
<queries>
<intent>
<action android:name="android.speech.RecognitionService" />
</intent>
</queries>Pass the result that matches the microphone permission state:
| What Android reports | Result to pass |
|---|---|
SpeechRecognizer.isRecognitionAvailable() returns false | Not granted, unsupported |
RECORD_AUDIO granted | Granted, granted |
| Denied in the dialog | Not granted, denied |
| Denied, and Android showed no dialog | Not granted, permanently_denied |
- Limitations:
- The default Android recognizer can send audio to remote servers.
- Speech recognition and Microphone share the
RECORD_AUDIOpermission. After the user grants one of them, or Android stops showing its dialog, a request for the other one returns the same permission state without a dialog.
Personal data
Contacts
- What the user sees: A runtime permission dialog.
- Setup: Declare the
READ_CONTACTSpermission inAndroidManifest.xml. If the app writes contacts, declare theWRITE_CONTACTSpermission too.
Pass the result that matches the contacts permission state:
| What Android reports | Result to pass |
|---|---|
| Granted | Granted, granted |
| Denied in the dialog | Not granted, denied |
| Denied, and Android showed no dialog | Not granted, permanently_denied |
Calendar
- What the user sees: A runtime permission dialog.
- Setup: Declare the
READ_CALENDARpermission inAndroidManifest.xml. To add events, declare theWRITE_CALENDARpermission too. Request both permissions together.
Pass the result that matches the calendar permission state:
| What Android reports | Result to pass |
|---|---|
| Granted | Granted, granted |
| Denied in the dialog | Not granted, denied |
| Denied, and Android showed no dialog | Not granted, permanently_denied |
- Limitations: To add an event without calendar access, use a calendar intent with the
ACTION_INSERTaction.
Health data
- What the user sees: The Health Connect permissions screen, with an entry for each data type. Health Connect shows this screen instead of a runtime permission dialog.
- Setup:
- Add the Health Connect client library,
androidx.health.connect:connect-client, to your app. - Add a
<uses-permission>element toAndroidManifest.xmlfor each data type and access, such as theandroid.permission.health.READ_STEPSpermission. Declare the same data types in the Google Play Console. - Add an
Activitythat shows your privacy policy for theandroidx.health.ACTION_SHOW_PERMISSIONS_RATIONALEaction. For Android 14 and later, add an<activity-alias>element for theandroid.intent.action.VIEW_PERMISSION_USAGEaction, with theandroid.intent.category.HEALTH_PERMISSIONScategory and theandroid:permission="android.permission.START_VIEW_PERMISSION_USAGE"attribute. - Add a
<queries>element with thecom.google.android.apps.healthdatapackage. - Call the
HealthConnectClient.getSdkStatus()method first, then request the permissions with the contract from thePermissionController.createRequestPermissionResultContract()method. Health Connect needs Android 9 (API 28) or later. Android 14 and later include it. On Android 13 and earlier, the user needs the Health Connect app from Google Play: when thegetSdkStatus()method returns theSDK_UNAVAILABLE_PROVIDER_UPDATE_REQUIREDstatus, the app can send the user to Google Play.
- Add the Health Connect client library,
Pass the result that matches the health data access:
| What Android reports | Result to pass |
|---|---|
getSdkStatus() doesn’t return SDK_AVAILABLE | Not granted, unsupported |
| All requested permissions granted | Granted, granted |
| Some requested permissions granted | Granted, limited |
| No permission granted, including the second cancel in a row | Not granted, denied |
| No permission granted, and the app counted two cancels in a row before this request: Health Connect showed no screen | Not granted, permanently_denied |
| Reading the granted permissions fails | Not granted, no argument |
- How to pass the result: After the user cancels the Health Connect screen twice in a row, the user can grant the permissions only in the Health Connect settings. Health Connect reports no cancel, so your app counts every request that returns no grant as a cancel. On the request that follows two cancels in a row, pass a not-granted result with
permanently_denied. Android can recreate theActivitywhile the Health Connect screen is open, for example on rotation. To pass the result to the flow after a recreation, keep thecallbackparameter of theonShowRequestPermissionmethod in aViewModel, which Android keeps across the recreation. - Limitations: Health Connect gives access to data from 30 days before the grant, unless the app also has the
PERMISSION_READ_HEALTH_DATA_HISTORYpermission.
Motion & Fitness
- What the user sees: On Android 10 and later, a runtime permission dialog for physical activity.
- Setup: Declare the
ACTIVITY_RECOGNITIONpermission inAndroidManifest.xml. On Android 10 (API 29) and later,ACTIVITY_RECOGNITIONis a runtime permission. It covers the step counter and step detector sensors and the Activity Recognition API. On Android 9 and earlier, Google Play services’ Activity Recognition API uses the install-time permissioncom.google.android.gms.permission.ACTIVITY_RECOGNITION.
Pass the result that matches the physical activity permission state:
| What Android reports | Result to pass |
|---|---|
| Granted | Granted, granted |
| Denied in the dialog | Not granted, denied |
| Denied, and Android showed no dialog | Not granted, permanently_denied |
| On Android 9 and earlier, no runtime permission | Granted, granted |
Device and home
Bluetooth
- What the user sees: On Android 12 and later, a Nearby devices dialog for apps that target Android 12 or higher. Otherwise, the location dialog.
- Setup: If the app targets Android 12 (API 31) or higher, declare the
BLUETOOTH_SCANandBLUETOOTH_CONNECTpermissions for Android 12 and later. To advertise, declare theBLUETOOTH_ADVERTISEpermission too. On Android 11 and earlier, and for apps that target a lower API level, Bluetooth scans need theACCESS_FINE_LOCATIONpermission. Android 9 and earlier also accept theACCESS_COARSE_LOCATIONpermission. Scans in the background on Android 10 and 11 also need theACCESS_BACKGROUND_LOCATIONpermission. On Android 11 and earlier, and for apps that target a lower API level,BLUETOOTHandBLUETOOTH_ADMINare install-time permissions:
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />Pass the result that matches the Bluetooth permission state:
| What Android reports | Result to pass |
|---|---|
The device has no Bluetooth: FEATURE_BLUETOOTH is missing, or FEATURE_BLUETOOTH_LE for a BLE app | Not granted, unsupported |
| All requested permissions granted | Granted, granted |
| Denied in the dialog | Not granted, denied |
| Denied, and Android showed no dialog | Not granted, permanently_denied |
On Android 11 and earlier, or for a target below API 31, the permission state of ACCESS_FINE_LOCATION. Approximate location isn’t enough for scans on Android 10 and 11 | As for Location while using the app |
- How to pass the result: A Bluetooth adapter that is turned off isn’t a refusal. Pass the result that matches the permission state, not the adapter state.
- Limitations:
- When the app sets the
neverForLocationflag, Android filters some BLE beacons out of scan results. - Bluetooth is in the Nearby devices group, which the user turns on and off as one in the settings.
- When the app sets the
Local network
- What the user sees: On Android 17 and later, a runtime permission dialog for apps that target Android 17 or higher. Otherwise, no dialog: the app accesses the local network with the
INTERNETpermission. - Setup: If the app targets Android 17 (API 37) or higher, declare the
ACCESS_LOCAL_NETWORKpermission inAndroidManifest.xml. If the app targets a lower API level, don’t declare or request this permission.NEARBY_WIFI_DEVICESis a different permission.
Pass the result that matches the local network permission state:
| What Android reports | Result to pass |
|---|---|
The app targets Android 16 or lower, or the device runs Android 16 or earlier: access comes with INTERNET | Granted, granted |
| The app targets Android 17 or higher, and the permission is granted | Granted, granted |
| The app targets Android 17 or higher, denied in the dialog | Not granted, denied |
| The app targets Android 17 or higher, denied, and Android showed no dialog | Not granted, permanently_denied |
- Limitations:
- On Android 17, the
ACCESS_LOCAL_NETWORKpermission is in the Nearby devices group. If the user granted another permission of the group, such as Bluetooth, Android shows no dialog for the local network. Android can also let the app ask again after an earlier refusal. - On Android 17, system pickers, such as the Output Switcher and the
NsdManagerclass with theFLAG_SHOW_PICKERflag, give the app access to the device that the user picks without this permission. See Local network permission.
- On Android 17, the
Permissions that Android doesn’t have
When a flow requests one of the following permissions, your app passes a not-granted result with unsupported, without a dialog:
- App tracking (ATT): The advertising ID on Android uses the install-time permission
com.google.android.gms.permission.AD_ID, which asks the user nothing. Don’t passgrantedbecause the app has an advertising ID. - Apple Music.
- Reminders: Android has no system reminders store. The
CalendarContract.Reminderstable contains the alarms of calendar events, not reminders. - HomeKit.
- Focus status: Android apps read the Do Not Disturb mode without a permission.
- Siri.