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

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

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 , 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, or permanently_denied to 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. Use limited if the user granted part of the access, such as a selection of photos. Use provisional for 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. Use restricted if a device policy, such as parental controls, blocks the permission. Use permanently_denied if 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 a true or false value for each permission: whether your app requested it before. The method returns false before 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 happenedshouldShowRequestPermissionRationale()The app requested the permission beforeArgument
    The user declined in the dialogtrue before or after the requestAnydenied
    Android showed no dialog after an earlier refusalfalse before and after the requestYespermanently_denied
    The user closed the first dialog without making a choicefalse before and after the requestNoNo 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 returns false before and after the request. Android doesn’t report whether it showed the dialog, so no code can tell these cases apart. Your app passes permanently_denied for 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 Activity on screen: An Activity is the Android component that shows a screen of your app. While the flow is shown, request the permission from the Activity that is on screen: Android delivers the user’s choice only to a resumed Activity. When the flow has its own Activity, a request from the Activity behind it returns the user’s choice only after the flow closes. A flow has its own Activity when the Flutter SDK shows it with the present() 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 the Activity of 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. The adb shell pm revoke and pm clear-permission-flags commands only reset the permission: its saved value stays true. Don’t install the test build with the adb install -g command: 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 to AndroidManifest.xml. On Android 13 (API 33) and later, POST_NOTIFICATIONS is 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 an Activity. 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 the NotificationManagerCompat.areNotificationsEnabled() method, which returns whether notifications are on.

Pass the result that matches the notification permission state:

What Android reportsResult to pass
GrantedGranted, granted
Denied in the dialogNot granted, denied
Denied, and Android showed no dialogNot granted, permanently_denied
The user swiped the dialog away on the first requestNot granted, no argument
On Android 12 and earlier, notifications are onGranted, granted
On Android 12 and earlier, notifications are offNot granted, permanently_denied
  • Limitations: On Android 13 and later, the user can block notifications for the app in the settings while the POST_NOTIFICATIONS permission stays granted. The areNotificationsEnabled() method then returns false. If the flow needs visible notifications, call the areNotificationsEnabled() method too. When it returns false, 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_LOCATION permission, the user can only grant approximate location.
  • Setup: Declare the ACCESS_COARSE_LOCATION permission in AndroidManifest.xml. To request precise location, declare the ACCESS_FINE_LOCATION permission too. Request both permissions together: some Android 12 releases ignore a request for the ACCESS_FINE_LOCATION permission alone.

Pass the result that matches the location permission state:

What Android reportsResult to pass
Precise or approximate location grantedGranted, granted
Denied in the dialogNot granted, denied
Denied, and Android showed no dialogNot 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_LOCATION and ACCESS_FINE_LOCATION permissions in AndroidManifest.xml. For Android 10 (API 29) and later, declare the ACCESS_BACKGROUND_LOCATION permission 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 reportsResult to pass
Foreground location not granted in its requestAs for Location while using the app: denied, permanently_denied, or no argument
Background location grantedGranted, granted
Background location not granted when the user comes back, or Android showed no settings pageNot granted, denied
On Android 9 and earlier, foreground location grantedGranted, 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_LOCATION permission receives precise location.
  • Setup: Declare the ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permissions in AndroidManifest.xml. When only approximate location is granted, request both permissions again.

Pass the result that matches the location accuracy:

What Android reportsResult to pass
ACCESS_FINE_LOCATION granted, including Only this timeGranted, granted
Only ACCESS_COARSE_LOCATION granted after the requestNot granted, denied
No location access, denied in the dialogNot granted, denied
No location access, and Android showed no dialogNot granted, permanently_denied
On Android 11 and earlier, ACCESS_FINE_LOCATION grantedGranted, 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 CAMERA runtime permission in AndroidManifest.xml. The CAMERA permission implies the required features android.hardware.camera and android.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 reportsResult to pass
Granted, including Only this timeGranted, granted
Denied in the dialogNot granted, denied
Denied, and Android showed no dialogNot granted, permanently_denied
The device has no camera: FEATURE_CAMERA_ANY is missingNot 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_AUDIO runtime permission in AndroidManifest.xml.

Pass the result that matches the microphone permission state:

What Android reportsResult to pass
Granted, including Only this timeGranted, granted
Denied in the dialogNot granted, denied
Denied, and Android showed no dialogNot 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_IMAGES and READ_MEDIA_VIDEO permissions together. On Android 14 and later, add the READ_MEDIA_VISUAL_USER_SELECTED permission to this request. On Android 12 and earlier, request the READ_EXTERNAL_STORAGE permission. Declare all four permissions in AndroidManifest.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 reportsResult to pass
On Android 13 and later, READ_MEDIA_IMAGES or READ_MEDIA_VIDEO grantedGranted, granted
On Android 14 and later, only READ_MEDIA_VISUAL_USER_SELECTED grantedGranted, limited
On Android 12 and earlier, READ_EXTERNAL_STORAGE grantedGranted, granted
Nothing granted, denied in the dialogNot granted, denied
Nothing granted, and Android showed no dialogNot granted, permanently_denied
  • Limitations:
    • Google Play restricts the READ_MEDIA_IMAGES and READ_MEDIA_VIDEO permissions 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_SELECTED permission. In an app that targets Android 14 or higher and doesn’t declare this permission, Android reports the READ_MEDIA_IMAGES and READ_MEDIA_VIDEO permissions as granted after the user selects some photos. After the app goes to the background, Android eventually revokes that grant. Your app then passes granted for access to a selection only.
    • Access to the selected media on Android 14 expires eventually.

Media library

  • What the user sees: A runtime permission dialog.
  • Setup: For Android 13 and later, declare the READ_MEDIA_AUDIO permission in AndroidManifest.xml. For Android 12 and earlier, declare the READ_EXTERNAL_STORAGE permission with the android:maxSdkVersion="32" attribute.

Pass the result that matches the audio permission state:

What Android reportsResult to pass
GrantedGranted, granted
Denied in the dialogNot granted, denied
Denied, and Android showed no dialogNot granted, permanently_denied
  • Limitations: Android has no partial access to audio files: the READ_MEDIA_VISUAL_USER_SELECTED permission 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_AUDIO permission in AndroidManifest.xml. The SpeechRecognizer class 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 reportsResult to pass
SpeechRecognizer.isRecognitionAvailable() returns falseNot granted, unsupported
RECORD_AUDIO grantedGranted, granted
Denied in the dialogNot granted, denied
Denied, and Android showed no dialogNot granted, permanently_denied
  • Limitations:
    • The default Android recognizer can send audio to remote servers.
    • Speech recognition and Microphone share the RECORD_AUDIO permission. 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_CONTACTS permission in AndroidManifest.xml. If the app writes contacts, declare the WRITE_CONTACTS permission too.

Pass the result that matches the contacts permission state:

What Android reportsResult to pass
GrantedGranted, granted
Denied in the dialogNot granted, denied
Denied, and Android showed no dialogNot granted, permanently_denied

Calendar

  • What the user sees: A runtime permission dialog.
  • Setup: Declare the READ_CALENDAR permission in AndroidManifest.xml. To add events, declare the WRITE_CALENDAR permission too. Request both permissions together.

Pass the result that matches the calendar permission state:

What Android reportsResult to pass
GrantedGranted, granted
Denied in the dialogNot granted, denied
Denied, and Android showed no dialogNot granted, permanently_denied
  • Limitations: To add an event without calendar access, use a calendar intent with the ACTION_INSERT action.

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 to AndroidManifest.xml for each data type and access, such as the android.permission.health.READ_STEPS permission. Declare the same data types in the Google Play Console.
    • Add an Activity that shows your privacy policy for the androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE action. For Android 14 and later, add an <activity-alias> element for the android.intent.action.VIEW_PERMISSION_USAGE action, with the android.intent.category.HEALTH_PERMISSIONS category and the android:permission="android.permission.START_VIEW_PERMISSION_USAGE" attribute.
    • Add a <queries> element with the com.google.android.apps.healthdata package.
    • Call the HealthConnectClient.getSdkStatus() method first, then request the permissions with the contract from the PermissionController.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 the getSdkStatus() method returns the SDK_UNAVAILABLE_PROVIDER_UPDATE_REQUIRED status, the app can send the user to Google Play.

Pass the result that matches the health data access:

What Android reportsResult to pass
getSdkStatus() doesn’t return SDK_AVAILABLENot granted, unsupported
All requested permissions grantedGranted, granted
Some requested permissions grantedGranted, limited
No permission granted, including the second cancel in a rowNot granted, denied
No permission granted, and the app counted two cancels in a row before this request: Health Connect showed no screenNot granted, permanently_denied
Reading the granted permissions failsNot 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 the Activity while the Health Connect screen is open, for example on rotation. To pass the result to the flow after a recreation, keep the callback parameter of the onShowRequestPermission method in a ViewModel, 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_HISTORY permission.

Motion & Fitness

  • What the user sees: On Android 10 and later, a runtime permission dialog for physical activity.
  • Setup: Declare the ACTIVITY_RECOGNITION permission in AndroidManifest.xml. On Android 10 (API 29) and later, ACTIVITY_RECOGNITION is 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 permission com.google.android.gms.permission.ACTIVITY_RECOGNITION.

Pass the result that matches the physical activity permission state:

What Android reportsResult to pass
GrantedGranted, granted
Denied in the dialogNot granted, denied
Denied, and Android showed no dialogNot granted, permanently_denied
On Android 9 and earlier, no runtime permissionGranted, 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_SCAN and BLUETOOTH_CONNECT permissions for Android 12 and later. To advertise, declare the BLUETOOTH_ADVERTISE permission too. On Android 11 and earlier, and for apps that target a lower API level, Bluetooth scans need the ACCESS_FINE_LOCATION permission. Android 9 and earlier also accept the ACCESS_COARSE_LOCATION permission. Scans in the background on Android 10 and 11 also need the ACCESS_BACKGROUND_LOCATION permission. On Android 11 and earlier, and for apps that target a lower API level, BLUETOOTH and BLUETOOTH_ADMIN are 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 reportsResult to pass
The device has no Bluetooth: FEATURE_BLUETOOTH is missing, or FEATURE_BLUETOOTH_LE for a BLE appNot granted, unsupported
All requested permissions grantedGranted, granted
Denied in the dialogNot granted, denied
Denied, and Android showed no dialogNot 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 11As 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 neverForLocation flag, 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.

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 INTERNET permission.
  • Setup: If the app targets Android 17 (API 37) or higher, declare the ACCESS_LOCAL_NETWORK permission in AndroidManifest.xml. If the app targets a lower API level, don’t declare or request this permission. NEARBY_WIFI_DEVICES is a different permission.

Pass the result that matches the local network permission state:

What Android reportsResult to pass
The app targets Android 16 or lower, or the device runs Android 16 or earlier: access comes with INTERNETGranted, granted
The app targets Android 17 or higher, and the permission is grantedGranted, granted
The app targets Android 17 or higher, denied in the dialogNot granted, denied
The app targets Android 17 or higher, denied, and Android showed no dialogNot granted, permanently_denied
  • Limitations:
    • On Android 17, the ACCESS_LOCAL_NETWORK permission 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 NsdManager class with the FLAG_SHOW_PICKER flag, give the app access to the device that the user picks without this permission. See Local network permission.

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 pass granted because the app has an advertising ID.
  • Apple Music.
  • Reminders: Android has no system reminders store. The CalendarContract.Reminders table contains the alarms of calendar events, not reminders.
  • HomeKit.
  • Focus status: Android apps read the Do Not Disturb mode without a permission.
  • Siri.