Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to forget the "Never ask again" choice in Android M runtime permission dialog

enter image description here

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!

like image 216
WindRider Avatar asked Nov 09 '15 13:11

WindRider


People also ask

How do you change dont ask again?

Go to Settings > Devices > Autoplay to look for the device and change the default behavior in it's Dropdown Menu.

How can I customize permissions dialog in Android?

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.

How do you ask permission runtime again if the user deny for the first time in React native?

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.


2 Answers

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.

like image 169
CommonsWare Avatar answered Oct 10 '22 04:10

CommonsWare


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.

like image 22
Nabin Bhandari Avatar answered Oct 10 '22 02:10

Nabin Bhandari