javaandroidpermissions

Android SDK 34 AppCompatActivity.requestPermissions does not display permission dialog, but does with Android SDK 29


Originally I was trying to update my already published application with targetSdkVersion 30, to be compliant with Google's targetSdkVersion 33 requirement. This just made all kinds of trouble. I had to update my IAP calls, as well as Advert calls. I managed to update to the new API methods and start testing only to find that requesting permissions are no longer working! (apologies for the frustration rant).

I understand about the permissions flow; declare what you need in the AndroidManifest.xml, then checking if shouldShowRequestPermissionRationale(), then make a call to requestPermissions(). Finally handle the user response in onRequestPermissionsResult().

On the old build, Android 29 (tablet), and Android 34 (phone) everything works as expected. When launching the application the file permissions dialog shows as the app starts up.

Now with the updated version, Android 29 (tablet), the file permission dialog shows, and the app continues. With Android 34 (phone) the file permission dialog does not show, and while debugging the onRequestPermissionsResult() method is called immediately with PERMISSION_DENIED response. The app is acting as if the user selected Deny & Don't Ask Again option from the permission dialog. The user is never offered the opportunity to accept, so the application informs the user and shuts down, as saving and sharing edited photos is the main function of the application.

What puzzles me is that the same build works on Android 29, but not on Android 34. So I'm inclined to believe the issue is with Android 34, unless there are some additional steps to take with the new API that is not required on Android 29.

Has anyone else come across a similar issue? If so, how did you resolve it?

EDIT: Within my AppCompatActivity I'm requesting:

String[] permissionList = { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE };
requestPermissions( permissionList, READ_STORAGE_RESPONSE );

Solution

  • String[] permissionList = { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE };

    On Android 13+ devices these permissions are not needed and do nothing.

    Do not ask them at runtime.

    Your app has write permission by default in all public directories on external storage.