MANAGE_EXTERNAL_STORAGE doesn't work for android 11 device

Viewed 27

I added the manage_external_storage to my androidmainifest.xml file and to my java class where the permission part is yet it is not working for my android 11 device. I previously had only the read and write external storage permissions and this worked for older versions, but once I tried it on an android 11 device it closes whenever I choose allow or don't allow options when trying to access to photos and media on my device for the pop-up question. How do I fix this? The only code that I added after I noticed this problem is Manifest.permission.READ_EXTERNAL_STORAGE <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"></uses-permission>. If there is anything more you need to see in terms of code let me know so I can post it. Also let me know if this manage_external_storage is accepted by the google app store as I am working on an app as I heard that the google app store does not accept this method due to a privacy issue, but I'm not sure if this is true or not.

first image of code

second image of code

1 Answers

For android 11, try this

if (Environment.isExternalStorageManager()) {
    //todo when permission is granted
} else {
    //request for the permission
    Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
    Uri uri = Uri.fromParts("package", getPackageName(), null);
    intent.setData(uri);
    startActivity(intent);
}

you can check the other answers of this question also

Related