I'm asking for the MANAGE_EXTERNAL_STORAGE permission:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="AllFilesAccessPolicy" /> <application ...
And I'm calling this function from the Activity's onCreate:
@RequiresApi(Build.VERSION_CODES.R) fun checkStoragePermission() { Manifest.permission.MANAGE_EXTERNAL_STORAGE.let { val permission = ContextCompat.checkSelfPermission(this,it) Log.d("--- MusinK ---", "MANAGE_EXTERNAL_STORAGE: $permission") if (permission != PackageManager.PERMISSION_GRANTED) { Log.d("--- MusinK ---", "requesting...") requestPermissions(this, arrayOf(it), 7) } } }
The value for permission is -1 and requesting... is logged, but there is no corresponding user dialog. What am I missing?
Note: I don't care for Google's policies. This app won't go to the PlayStore. I have my phone connected via USB, and when I hit run in Android Studio, I want to see the dialog.
I have deleted the app several times already; thus, this is not caused by previous denials.
The reason you aren't seeing a dialog is that MANAGE_EXTERNAL_STORAGE is a special app access permission, not a standard runtime permission. Therefore it cannot be granted via the usual requestPermissions() dialog. You must use an Intent to send the user to the specific system settings page:
if (!Environment.isExternalStorageManager()) { val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION) intent.data = Uri.parse("package:$packageName") startActivity(intent) }
Because your app is for private use only, this is the correct way to bypass in Android 11+.