Lompat ke konten Lompat ke sidebar Lompat ke footer

Android 11 With if else For Check MANAGE_EXTERNAL_STORAGE Permission

 For My GSyntax project i use and add MANAGE_EXTERNAL_STORAGE Permission, so for check this permission im using this code below, This Programmatically MANAGE_EXTERNAL_STORAGE For Android 11


But this code can be using on android 11 below like a android 10 & 9 but in android 10 below  this code is ignored by system


//Android 11 if else For Check MANAGE_EXTERNAL_STORAGE Permission
if (Environment.isExternalStorageManager()) {
//Here todo when permission is granted

}
else {
//request for the permission
if (SDK_INT >= Build.VERSION_CODES.R){
    Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivity(intent);
    }
}

if Environment.isExternalStorageManager Error you can fix by ALT + Enter

Thanks for visit, this code i hope you understand and work

close