I recently got curious about what happens to the runtime permissions state when the user revokes or grants a permission using the OS Settings app, rather than allowing or denying in the dialog prompt that an app can show to request permission.
For background, there are two parts to the state that an app can query at any time:
- checkSelfPermission() returns PERMISSION_GRANTED or PERMISSION_DENIED, meaning that your app either has that permission, or it doesn’t.
- shouldShowRequestPermissionRationale() returns true or false. True means that the user has previously denied your request for this permission, so you should explain to the user why your app needs this permission. This returns false if the user denies the permission and checks the “don’t ask again” box.
The question I got curious about was this: what happens when the user revokes a permission in the settings app? If they had previously chosen “don’t ask again”, but then later grant the permission in settings, then revoke the permission again, can you prompt for the permission?
I made a simple app to try it out, and came up with this for the possible states:The answer is that if the user revokes a permission in settings, all of that history essentially goes away. You’re left in the same state as if you had asked for permission and the user had denied it once, but you can ask again.
I realize this isn’t the sort of thing that’s going to happen in the course of normal usage; I don’t expect most users to ever toggle those permissions from the settings app. But I think it’s worth understanding how it works.