I wish to know where the "Never ask again" checkbox boolean flag is stored and how to clear its value? Not necessarily programmatically, but manually - via setting, command or some tool. Tried clearing app data, uninstall, both uninstall and clear, tried manual switching the permissions on/off back and forth, tried even setting up a newer Marshmallow image for the emulator but no luck!
Go to Settings > Devices > Autoplay to look for the device and change the default behavior in it's Dropdown Menu.
The short answer is, you can't. As android documentation puts: When your app calls requestPermissions(), the system shows a standard dialog box to the user.
I don't think you should ask permission again if the user denies, all you can do is, don't take the app forward , just show them a toast or a dialog telling them that this permission is required for the app to work correctly and ask them to grant permission in the settings.
Both clearing data (Settings > Apps > your app > Storage > Clear Data) and uninstalling the app clear the status of this flag, along with clearing everything else related to runtime permissions for the app.
This behavior was tested on a Nexus 5 running Android 6.0, via this sample app.
I seem to recall seeing a manual option for this somewhere, but I can't find it now. It may be something that existed back in the M Developer Preview releases and got pulled for the final 6.0 release.
You can "forget" it by clearing the data from app's settings.
EDIT: As @me_ pointed out, just clearing app data may not reset the "don't ask again" condition in some devices. In such cases manually turning on and then turning off the permissions from app's settings will do the trick.
But if you want to find if a permission has been set not to request again you can check it programatically by using the onRequestPermissionsResult()
method.
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
for(String permission: permissions){
if(ActivityCompat.shouldShowRequestPermissionRationale(this, permission)){
//denied
}else{
if(ActivityCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED){
//allowed
} else{
//set to never ask again
Log.e("set to never ask again", permission);
}
}
}
}
PS: I have answered full implementation at this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With