8

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!

WindRider
  • 11,958
  • 6
  • 50
  • 57

6 Answers6

9

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I use the emulator - nothing works. Could you test on emulator please? – WindRider Nov 09 '15 at 13:28
  • @WindRider: Both approaches work fine with that sample app on an Android 6.0 emulator as well. – CommonsWare Nov 09 '15 at 13:32
  • The problem was in my code. I was using permission groups instead of permissions. This caused the system to return PERMISSION_DENIED right away everytime no matter what. – WindRider Nov 09 '15 at 13:47
  • 1
    @WindRider: Yeah, you're not the first person to do that, and probably you won't be the last. It'd be nice if there was a separate return code (`PERMISSION_WTF`) for unrecognized permission names or something. – CommonsWare Nov 09 '15 at 13:55
  • Logically speaking now in M they store one flag for the whole permission group instead one flag per each granular permission. So i made a wrong assumption that I can use permission groups everywhere without problems. – WindRider Nov 09 '15 at 14:01
  • as i pointed out a year and a half ago... this doesn't work. https://www.youtube.com/watch?v=F8hQfmYTEaQ – me_ Mar 14 '20 at 23:19
  • @me_: "Clear data" worked just fine for me in a test now, using a Pixel 4 running Android 10, a Samsung Galaxy S9 running Android 10, and a Samsung Galaxy S8 running Android 9. This is in addition to the original test, run 4.5 years ago, on a Nexus 5 running Android 6.0. I certainly cannot rule out the possibility that it does not work on some devices. – CommonsWare Mar 14 '20 at 23:39
  • I presented the general solution... i also tested your method, and posted a video of it failing. – me_ Mar 16 '20 at 00:11
7

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.

Nabin Bhandari
  • 15,949
  • 6
  • 45
  • 59
  • @me_ Android never fails to amaze us with its flaws. Looks like it is a device specific problem. Or does it happen in all devices? By the way, my library may be of some help to you. Try this: https://github.com/nabinbhandari/Android-Permissions – Nabin Bhandari Jun 20 '18 at 09:36
  • I presented the general solution... https://stackoverflow.com/questions/37130838/android-runtime-permission-for-system-apps/37131623#37131623 – me_ Jun 20 '18 at 09:56
3

Found it:

System Settings > Apps > Reset App Preferences (in the menu)

enter image description here

WindRider
  • 11,958
  • 6
  • 50
  • 57
  • 1
    tested with emulator, this simply does not work. I bet you changed the permissions manually before you did this. – me_ Jun 20 '18 at 07:07
2

Only solution that worked for me is:

  1. Go to the Apps Permission
  2. Enable and disable all permissions

It will then forget the "Never ask again" choice

App permissions list

You can check it out in this video https://www.youtube.com/watch?v=F8hQfmYTEaQ

Dawit Abraham
  • 1,616
  • 15
  • 19
  • so exactly what i said (while posting a video testing all other solutions provided on this page) a year and a half before you... – me_ Mar 14 '20 at 23:16
  • 1
    I usually don't like to go through a whole video for info I can get from a glimpse of a picture. – Dawit Abraham Mar 24 '20 at 10:40
1
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
    boolean dontAsk = false;
    if (requestCode == REQUEST_CAM_STORAGE_PERMISSION) {
        for (String allowedPermissions : permissions) {
            if (ActivityCompat.shouldShowRequestPermissionRationale(context, allowedPermissions)) {
                Log.e("Permission: ", "User Has Denied Permission");
            } else if (PermissionChecker.checkCallingOrSelfPermission(context, allowedPermissions) != PackageManager.PERMISSION_GRANTED) {
                Log.e("Permission: ", "User Has Denied Permission with Don't Ask Again");
                dontAsk = true;
                break;
            } else {
                Log.e("Permission: ", "User Has Allowed Permission");
            }
        }

        if (!dontAsk) {
            Log.e("Permission: ", "Dont'Ask False");
            checkPermission();
        } else {
            Log.e("Permission: ", "Dont'Ask True");
            startActivity(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + this.getPackageName())));
        }
    }
}
Ketan Ramani
  • 4,874
  • 37
  • 42
0

https://www.youtube.com/watch?v=F8hQfmYTEaQ

You should Enable and the Disable the permissions manually in the settings->apps permissions area.

I tried all suggestions given on this page. None of them worked. Manual enable and disable returned the dialog box.

click the youtube post above to verify this is the correct answer

me_
  • 681
  • 1
  • 8
  • 18