androidandroid-permissionsandroid-external-storage

Android permission READ_MEDIA_AUDIO and READ_EXTERNAL_STORAGE for API level < 33


In API 33 (Android 13), granular media permissions have been introduced, and developers have to request these granular permissions instead of READ_EXTERNAL_STORAGE.

READ_MEDIA_AUDIO is one such granular permission. This permission exists only in API level 33+, so my question is, which permission should I request in the manifest?

Since my app has minSDK = 21, should I request both READ_EXTERNAL_STORAGE and READ_MEDIA_AUDIO in the manifest. Or should I only request READ_EXTERNAL_STORAGE and that will cover READ_MEDIA_AUDIO? (At runtime, of course, I will ask for either of the permission based on the SDK_INT of the device.)


Solution

  • You should add both permissions to your manifest

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
    

    The READ_MEDIA_AUDIO permission will work only for devices with Android 13 or above.

    Then, as you wrote, you should handle each case of the SDK (this section may be helpful for other developers):