Android M permission issue with Dialog "Don't ask again"

is any way to change that flag ?

A developer cannot change that flag. Otherwise, there would be no point in having the checkbox, as developers would just ignore it by changing the flag.

However, your question points out a fairly substantial flaw in the scoped directory access: the user has limited ability to change that flag. There does not appear to be a place in Settings to change this state specifically, the way the user can manually grant a rejected runtime permission.

On a Nexus 5X running the 7.1 preview, "Clear Data" will reset this flag, though that has broader effects. On a Google Pixel running 7.1, and on a Nexus 5X running Android 7.0, nothing will reset this flag, even a full uninstall of the app.

I have filed a bug report about this. I am skeptical that the situation will be improved much in the short term — at best, they might fix it so "Clear Data" works reliably.


Open Up the App's Permission Settings.

You cannot show another permissions dialog if the User has checked off "Don't ask again."

However, you can help the user and open up the App's Settings where the User can manually enable the Permissions required.

To do that you'll need to launch an intent, similar to this:

public void openAppSettings() {

    Uri packageUri = Uri.fromParts( "package", getApplicationContext().getPackageName(), null );

    Intent applicationDetailsSettingsIntent = new Intent();

    applicationDetailsSettingsIntent.setAction( Settings.ACTION_APPLICATION_DETAILS_SETTINGS );
    applicationDetailsSettingsIntent.setData( packageUri );
    applicationDetailsSettingsIntent.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );

    getApplicationContext().startActivity( applicationDetailsSettingsIntent );

}

Now, in order to know when the User has checked off the "Don't ask again" checkbox is another matter and can done with this StackOverflow answer.


I think what you need to do is use the method shouldShowRequestPermissionRationale(String) it would return false if user has denied the permission and checked "Don't ask again".

What you should do is show an alert explaining the user why you need the permission or implement a fallback, like disable some feature.

Hope to be helpful.