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.)
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):
READ_EXTERNAL_STORAGE
permission (https://developer.android.com/training/permissions/requesting)READ_EXTERNAL_STORAGE
permission. Regarding the changes, for example the directory Recordings
exists only from the SDK 31 (source: https://developer.android.com/training/data-storage/shared/media#media_store)READ_MEDIA_AUDIO