How should your app be updated for Android 13 given the changes to permissions?

Android Development
April 25, 20233 minutesuserVivek Beladiya
How should your app be updated for Android 13 given the changes to permissions?

The Android 13 version was just released. Because your audience will progressively switch to this new version, you as an app developer must support newer versions. Yes, it takes longer to adjust to new versions than it does for IOS, but you still need to do it.

Changes with the new version come in 3 categories:

  1. New Features and APIs.The overview of the new functionality and APIs can be found here. These modifications consist of brand-new APIs and functionality that were not present in earlier iterations. The Per-app language choices are the new feature that I loved the most. Users can now choose a language other than the system language for an app thanks to this functionality.

  2. Behaviour changes in all apps. The details about those adjustments are available here. No matter if your app targets API level 33 or not, these changes apply to all apps. You must test your app on Android 13 and make the necessary adjustments to make it suitable.

  3. Behavior changes Apps targeting Android 13 or higher. These changes can be found here. Only apps that target API level 33 or higher are impacted by these changes. You must make the necessary adjustments in order to work with Android 13.

In Android 13, there are some changes that are worth checking which could affect your app. These are mostly changes in permission behaviors.

NEARBY_DEVICES Permission

Starting with Android 13, you will need to use NEARBY_DEVICES permission for some Wi-Fi-related use cases. Previously, ACCESS_FINE_LOCATION permission was used.

New Permissions for Media

Three new permission is introduced with Android 13: READ_MEDIA_IMAGES, READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, and READ_MEDIA_AUDIO.Use one of these new permissions if you were reading files using READ_EXTERNAL_STORAGE. All is well if an Android 13 user has already granted this permission. If not, the request for READ_EXTERNAL_STORAGE permission will be disregarded. This indicates that for this section, your app needs to be modified.

In our program, we used READ_EXTERNAL_STORAGE to select images. For picture selection, we had to support READ_MEDIA_IMAGES. I'll now describe how you can accomplish this.

Firstly, you need to update compile and target api level to 33. Now you could access the new APIs :)

compile: 33,
target : 33

Secondly, you need to put READ_MEDIA_IMAGES permission to AndroidManifest file.

Lastly, you need to programatically ask for READ_EXTERNAL_STORAGE permission for API level lower than 33 and ask for READ_MEDIA_IMAGES permission for API level equal or higher than 33.


private val readImagePermission = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
if(ContextCompat.checkSelfPermission(this, readImagePermission) == PackageManager.PERMISSION_GRANTED){
    //permission granted
} else {
    //permission not granted
}

Thats it, now your app is supporting this new permission! Hope this tutorial helped you in migrating to the new permissions. Please provide a clap if you liked this post.