Application developers regularly face the need to request permissions - be it access to the camera, geolocation or contacts. With the release of Android-applications regularly face the need to request permissions - be it access to the camera, geolocation or contacts. With the exit Android 6.0 (Marshmallow) the permission system has undergone dramatic changes: many permissions now require not only a declaration at AndroidManifest.xmlbut also an explicit request at runtime (runtime permissions). This article will help you understand how to properly implement permission request in 2026, taking into account the latest platform updates and security best practices.
We will look at the entire process - from the basic declaration in the manifest to handling user responses, including the specifics of working with Android 13 (API 33) and Android 14 (API 34). We will pay special attention to typical errors that lead to application crashes or access denials, as well as the nuances of working with permissions for different OS versions. If you are just starting to develop under Android or want to update your knowledge, this guide is for you.
1. Types of permissions in Android: normal, dangerous and special
In Android all permissions are divided into three categories, each of which requires its own approach to the request. Understanding this classification is the basis for correct implementation.
Normal permissions (normal permissions) are automatically provided by the system when installing the application. They do not require an explicit request at runtime. Examples:
- ๐ถ
android.permission.INTERNETโ network access - ๐
android.permission.VIBRATEโdevice vibration - โฐ
android.permission.WAKE_LOCKโpreventing screen sleep
Dangerous permissions (dangerous permissions) โthe most critical group. They require the userโs explicit consent while the application is running. These include include:
- ๐ธ
android.permission.CAMERAโ access to the camera - ๐
android.permission.ACCESS_FINE_LOCATIONโ precise geolocation - ๐
android.permission.READ_CONTACTSโ reading contacts - ๐พ
android.permission.READ_EXTERNAL_STORAGEโ access to files (up to Android 10)
Special permissions (special permissions) - rarely used permissions that require either manual configuration in system settings or additional steps. Examples:
- ๐
android.permission.SYSTEM_ALERT_WINDOWโ display on top of other applications - ๐ฑ
android.permission.WRITE_SECURE_SETTINGSโ changing system settings - ๐
android.permission.BIND_NOTIFICATION_LISTENER_SERVICEโ access to notifications
โ ๏ธ Attention: Starting from Android 10 (API 29), permissionWRITE_EXTERNAL_STORAGElimited scoped storage. To work with files, useMediaStoreorStorage Access Framework.
2. Declaration of permissions in AndroidManifest.xml
The first step is to declare the necessary permissions in file AndroidManifest.xml. Without this, the system will not even allow the application to request permission from the user.
Add the necessary permissions inside the tag <manifest>:
<uses-permission android:name="android.permission.CAMERA" /><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
For permissions related to hardware capabilities (for example, camera or Bluetooth), you also need to specify the tag <uses-feature>, so Google Play can filter devices that do not support these features:
<uses-feature android:name="android.hardware.camera" android:required="false" />
Starting with Android 12 (API 31), the ACCESS_BACKGROUND_LOCATION permission requires an explicit setting in the manifest, even if it is requested as part of the LOCATION group.
| Resolution | Group | Requires a runtime request? | Features |
|---|---|---|---|
CAMERA |
Camera | Yes | Requires <uses-feature> |
READ_EXTERNAL_STORAGE |
Storage | Yes (up to API 33) | Replaced by READ_MEDIA_IMAGES in API 33+ |
ACCESS_FINE_LOCATION |
Location | Yes | Includes ACCESS_COARSE_LOCATION |
RECORD_AUDIO |
Microphone | Yes | Requires explanation when requested |
โ ๏ธ Attention: If your application is targeted Android 13 (API 33) or higher, permissions for accessing media files (READ_EXTERNAL_STORAGE) are replaced with more granular ones:READ_MEDIA_IMAGES,READ_MEDIA_VIDEOiREAD_MEDIA_AUDIO.
3. Requesting permissions at runtime (Runtime Permissions)
For dangerous permissions, only declaration in manifest - they need to be requested while the application is running. The process includes three key steps:
- Checking the current status โwhether permission needs to be requested.
- Requesting permission โcalling the system dialog.
- Response processing โactions depending on the user's choice.
Example of requesting permission for a camera on Kotlin:
// 1. Checking statusif (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
// 2. Requesting permission
ActivityCompat.requestPermissions(
this,
arrayOf(Manifest.permission.CAMERA),
REQUEST_CAMERA_PERMISSION
)
} else {
// Permission has already been granted
openCamera()
}
To process the response, override the method onRequestPermissionsResult:
override fun onRequestPermissionsResult(requestCode: Int,
permissions: Array<String>,
grantResults: IntArray
) {
when (requestCode) {
REQUEST_CAMERA_PERMISSION -> {
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
openCamera()
} else {
showPermissionDeniedMessage()
}
}
}
}
In Android 11 (API 30) and above it is recommended to use ActivityResultContracts.RequestPermission() instead of the outdated one onRequestPermissionsResult:
private val requestPermissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()
) { isGranted ->
if (isGranted) {
openCamera()
} else {
showPermissionDeniedMessage()
}
}
// Call
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
โ๏ธ Preparing to request permission
4. Explanation of the need for permissions (Permission Rationale)
Starting from Android 6.0, if the user has previously rejected the permission request, the system will show a dialog with checkbox "Do not ask again". In this case, a repeated request via requestPermissions() will not show the dialog, but will immediately return a refusal. To avoid this, before the request you need to explain to the user why the application needs permission.
Use the shouldShowRequestPermissionRationale():
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA)) {// Show an explanation (for example, AlertDialog)
showPermissionExplanationDialog()
} else {
// Request permission or redirect to settings
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
Examples of explanations for the user:
- ๐ธ "Access to the camera needed to scan QR codes and create a profile photo."
- ๐ "Geolocation helps show nearby stores and optimize routes."
- ๐พ "Access to files required to download and save your documents."
โ ๏ธ Attention: Do not overuse explanations - they should be short and specific. Long texts irritate users and increase the likelihood of refusal.
Use icons and illustrations in explanation dialogues - visual accompaniment increases user trust by 30% (according to Google UX research).
5. Handling permanent denial and redirecting to settings
If the user selected "More. do not ask" and denied the permission, calling again requestPermissions() will not show the dialog. In this case, you need to redirect the user to the application settings, where he can manually enable the permission.
Check for permanent refusal:
if (!ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA) &&ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
// Redirect to settings
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
intent.data = Uri.fromParts("package", packageName, null)
startActivity(intent)
}
It is important to warn the user that he will be redirected to settings. Example message:
"Permission deniedTo use the camera, enable access in the application settings Click 'OK' to proceed. go there now."
Some manufacturers (Xiaomi, Huawei, Oppo) modify Android and add additional levels of permissions. In such cases, you may need to:
- ๐ง Manually enable permission in "Settings โ Permissions โ Autorun" (for background tasks).
- ๐ฑ Resolution "Show on top of other applications" for overlay windows.
- ๐ Separate permission for "Changes to system settings" (for example, screen brightness).
What to do if the user does not return from the settings?
If the user does not return to the application after redirections to the settings, implement a permission check in onResume():
override fun onResume() {super.onResume()
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
openCamera()
}
}
6. Features of working with permissions in Android 13 and 14
Android 13 (API 33) i Android 14 (API 34) have made significant changes to the permissions system, especially for working with media files and notifications.
Main changes in API 33:
- ๐ผ๏ธ Resolution
READ_EXTERNAL_STORAGEoutdated. Instead, use:READ_MEDIA_IMAGESโ access to photosREAD_MEDIA_VIDEOโ access to videoREAD_MEDIA_AUDIOโ access to audio files
- ๐ New resolution
POST_NOTIFICATIONSโrequired for displaying notifications (previously did not require an explicit request). - ๐ฑ Permission
NEARBY_WIFI_DEVICESreplacesACCESS_FINE_LOCATIONfor scanning Wi-Fi devices.
An example of requesting permission for notifications:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
}
Changes in API 34 (Android 14):
- ๐ Access to files of other applications through
MediaStore. - ๐ Permission has been introduced
READ_MEDIA_VISUAL_USER_SELECTEDfor access only to user-selected media files. - ๐ Requirements for background geolocation - now requires explicit permission
ACCESS_BACKGROUND_LOCATIONeven for foreground services.
โ ๏ธ Attention: Starting Android 14, applications targeting API 34+ must request READ_MEDIA_VISUAL_USER_SELECTED instead of broad permissions for media files, unless they need access to ALL files on the device.
With Android 13 notifications permission has become mandatory. Without it, your push notifications will not be shown, even if they are critical to the functionality of the application.
7. data-i="196">Even experienced developers make mistakes when working with permissions. Here are the most common problems and how to avoid them:
Even experienced developers make mistakes when working with permissions. Here are the most common problems and how to avoid them:
Error 1: Asking for all permissions at once at startup
Users are more likely to deny permissions if they see a long list when they first open it. Solution: request permissions as needed (for example, camera permission - only when the user clicks the "Take Photo" button).
Error 2: Ignoring the Android version
Code running on Android 10may cause a crash on Android 13. Always check the OS version:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {// Logic for Android 13+
} else {
// Logic for older versions
}
Error 3: Lack of processing of โpartialโ consent
If you request several permissions at once (for example, camera + microphone), the user can only agree to one. Always check the status of each permission separately:
if (grantResults.isNotEmpty()) {val cameraGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED
val microphoneGranted = grantResults[1] == PackageManager.PERMISSION_GRANTED
// Process each result separately
}
Error 4: Forgetting to test on different manufacturers
Manufacturers (Samsung, Xiaomi, Huawei) often modify the behavior of permissions. Test the application on devices of different brands, especially if you use:
- ๐ Background services
- ๐ฑ Overlay windows
- ๐ Battery optimization
Error 5: Unclear explanations for the user
The phrase "This application needs permissions to work" is not informative. Indicate a specific reason:
Bad: "Requires access to contacts."
Good: "Access to contacts is needed to quickly select a message recipient. We do not transfer your contacts to the server."
8. Tools for debugging permissions
If permissions are not working as expected, use these diagnostic tools:
1. ADB commands to check permissions
View all application permissions:
adb shell dumpsys package <package_name> | grep "grant"
Reset permissions for testing:
adb shell pm revoke <package_name> android.permission.CAMERA
adb shell pm grant <package_name> android.permission.CAMERA
2. Android Studio Profiler
Use Logcat with a filter by tag "PackageManager"to track events related to permissions.
3. Libraries to simplify work
- ๐ ๏ธ PermissionsDispatcher โ annotations for automatic generation of request code.
- ๐ง EasyPermissions โ simplified processing of permissions from Google.
- ๐ฆ AndroidX Activity Result APIs - a modern way of working with permissions (recommended by Google).
4. Testing on an emulator
The emulator Android Studio allows you to simulate different failure scenarios. For example, to test a permanent failure:
- Run the application on the emulator.
- Reject permission and check the "Don't ask again".
- Check whether the application correctly redirects to settings.
To automatically test permissions in CI/CD use UI Automator or Espresso with system dialog mocks.
FAQ: Frequently asked questions about permissions in Android
โ How to request permission for notifications in Android 13?
Starting c Android 13 (API 33), showing notifications requires permission POST_NOTIFICATIONS. Add it to the manifest and request it at runtime:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {requestPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
}
Without this permission, notifications will not be shown, even if they are critical to the application logic.
โ Why the permission request does not show dialog?
This happens in two cases:
- The user previously selected "Don't ask again" and denied permission. Check this via
shouldShowRequestPermissionRationale(). - Permission has already been granted. Check the status via
ContextCompat.checkSelfPermission().
If this is the first case, redirect the user to the application settings.
โ How to request several permissions at once?
Use an array of permissions in requestPermissions():
ActivityCompat.requestPermissions(this,
arrayOf(
Manifest.permission.CAMERA,
Manifest.permission.RECORD_AUDIO
),
REQUEST_CODE_MULTIPLE_PERMISSIONS
)
B onRequestPermissionsResult check the status of each permission separately by index in array grantResults.
โ Is it necessary to request READ_EXTERNAL_STORAGE in Android 13?
No, in Android 13 this permission is obsolete. Instead, use:
READ_MEDIA_IMAGESโ for photosREAD_MEDIA_VIDEOโ for videoREAD_MEDIA_AUDIOโ for audio
If your application needs access to ALL media files, use READ_MEDIA_VISUAL_USER_SELECTED (the user selects specific files).
โ How to handle permissions on Xiaomi, Huawei and other devices manufacturers?
Some manufacturers add additional restrictions. For example:
- Xiaomi: requires "Autostart" permission for background tasks.
- Huawei: can block notifications if the application is not added to "Protected applications".
- Oppo/Realme: you need to manually allow "Display on top of other applications" for overlays.
It is recommended to add a screen with instructions for popular brands to the application or use libraries like AndroidAutoStart.