Reputation: 41
My application targets api level 32. When running on Android 13 device, ActivityResultContracts.RequestMultiplePermissions() always returns PERMISSION_DENIED even if the user presses on "Allow".
Also, when checking in settings->app->permissions, the IMAGE, AUDIO and VIDEO permissions get granted.
The documentation clearly states that applications targeting api level < 33 should continue asking for READ_EXTERNAL_DEVICE, and the IMAGE, AUDIO and VIDEO will be granted automatically
Tried allowing READ_EXTERNAL_STORAGE permission.
Expected to open Gallery.
Actually, permission was denied.
Upvotes: 4
Views: 2815
Reputation: 370
Apparently, From android 13 and beyond You need to put permissions for READ_MEDIA_VIDEO,READ_MEDIA_IMAGES,READ_MEDIA_AUDIO, not Just requesting READ_EXTERNAL_STORAGE will work alone, won't even show in the permission page in the settings
<!-- Required only if your app needs to access images or photos
that other apps created. -->
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<!-- Required only if your app needs to access videos
that other apps created. -->
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<!-- Required only if your app needs to access audio files
that other apps created. -->
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<!-- If your app doesn't need to access media files that other apps created,
set the "maxSdkVersion" attribute to "28" instead. -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="29" />
Upvotes: 3