In the main action of the Android application, I check the permissions ( Manifest.permission.MANAGE_DOCUMENTS ), find that I do not have them, and call requestPermisions . Then in onRequestPermissionResult I almost immediately get permission denied without displaying a dialog.
I already confirmed the same permission in another action of the same application (through requestPermissions again, that works), so I expected this solution to be saved (for the session or something else), and I never chose to refuse permission . In either case, the permission dialog is not displayed, and permission is automatically resolved.
So far I have tested this on Android 7 and 6 emulators (API 24 and 23).
I tried:
I am very confused ...
Here is a permission request (see comment in code):
private fun askForPermissionOrSendRequest(view: View, permission: String) { if (checkSelfPermission(permission) == PackageManager.PERMISSION_DENIED) { if (shouldShowRequestPermissionRationale(permission)) { cachedView = view val explanationDialog = AlertDialog.Builder(this).setMessage("We need permissions to read your storage in order to show your profile image.").setOnDismissListener { requestPermissions( arrayOf(permission), BSMainActivity.permissionRequestSendProfilePic ) }.create() explanationDialog.show() } else { cachedView = view
I immediately get to the result handler without a dialog box appearing to ask me about permissions. I may or could not confirm the same permission in another (child) action of the same application (it doesn't seem to matter).
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray ) { super.onRequestPermissionsResult(requestCode, permissions, grantResults) when (requestCode) { BSMainActivity.permissionRequestSendProfilePic -> { // This gets hit, MANAGE_DOCUMENTS was denied if (permissions.contains(Manifest.permission.MANAGE_DOCUMENTS) && grantResults[permissions.indexOf(Manifest.permission.MANAGE_DOCUMENTS)] == PackageManager.PERMISSION_DENIED) { Log.w(logName, "Permission to open image was denied while sending a tag request: %s %s".format( permissions.joinToString(",", "[", "]"), grantResults.joinToString(",", "[", "]") )) } // send request regardless of the result for now sendRequest(cachedView) } } }
In my manifest, I have the following:
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="me.monomon.bs"> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>