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

后端 未结 6 727
囚心锁ツ
囚心锁ツ 2020-12-10 06:33

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 settin

相关标签:
6条回答
  • 2020-12-10 06:47

    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

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

    0 讨论(0)
  • 2020-12-10 06:51

    Found it:

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

    0 讨论(0)
  • 2020-12-10 06:55

    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.

    0 讨论(0)
  • 2020-12-10 07:06

    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

    0 讨论(0)
  • 2020-12-10 07:08
    @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())));
            }
        }
    }
    
    0 讨论(0)
  • 2020-12-10 07:12

    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.

    0 讨论(0)
提交回复
热议问题