rideintothesun
rideintothesun

Reputation: 1678

Android RequestPermission when administrator does not allow them to be changed

I have a scenario where an android apps permissions are set by an administrator via an MDM which cannot be changed by the user of the device.

What will happen if when the permission is checked and the permission is denied. Then the code requests the permission, and the user selects to allow the permission.

What will happen if the administrator has set the permission to be fixed as denied?

Will the user be informed automatically via another dialog?

Will the onRequestPermissionsResult just state that the permission is denied in the passed array of grantResults?

Or does something else occur. I do not have a set up where I can test this. Hopefully someone can explain the outcome of this scenario

Upvotes: 0

Views: 167

Answers (1)

ianhanniballake
ianhanniballake

Reputation: 199805

As per the Explain why the app needs permission documentation:

One approach you might use is to provide an explanation only if the user has already denied that permission request. Android provides a utility method, shouldShowRequestPermissionRationale(), that returns true if the user has previously denied the request, and returns false if a user has denied a permission and selected the Don't ask again option in the permission request dialog, or if a device policy prohibits the permission.

So if you ask for permission, the permission will be immediately denied - the user won't see any permission prompt. If shouldShowrequestPermissionRationale() returns false, either the user has permanently denied your permission or the device policy has permanently denied your permission.

Upvotes: 1

Related Questions