nazmul idris
nazmul idris

Reputation: 442

Android M 6.0 permissions issue

I have an Android M app (targetSDK=23) and it needs location permissions. When the user grants this permission on a Moto X Play (pure edition) device, the app + system asks for the permissions every single time, even though the user has granted the permissions. I can see this permission granted in App Info, both before and after the system prompt appears and the user accepts. The behavior of the system is supposed to be such that it asks the user once for a grant once, and not subsequently (unless the permission is revoked, of course). This works as intended on both a Nexus 6P and 5X both running 6.0.1.

if(askForPermissions && act != null) {
 String[] permissionsToRequest = _getPermissions(set);
 ActivityCompat.requestPermissions(act, permissionsToRequest, GENERIC_SVC_PERM_REQUEST);
}else{
 startSmartServices();
}

Upvotes: 2

Views: 879

Answers (1)

Cognitio
Cognitio

Reputation: 410

Is your Moto X Play running 6.0 or 6.0.1? It seems likely that it is one of the system bugs they patched in 6.0.1 since both of the devices running this latest update of M seem to work. I verified that it works on my nexus 6p and 5x as well.

If you are not checking if you already have the permission using ContextCompat.checkSelfPermission(), then this would result in repeated requests for the same permission. As per the docs here:http://developer.android.com/training/permissions/requesting.html

"The user only needs to grant permission once for each permission group. If your app requests any other permissions in that group (that are listed in your app manifest), the system automatically grants them. When you request the permission, the system calls your onRequestPermissionsResult() callback method and passes PERMISSION_GRANTED, the same way it would if the user had explicitly granted your request through the system dialog box."

It could be that the system automatically grants access to the permission as explained above in 6.0.1, but will explicitly show the user the same dialog in 6.0 (relying on the dev to use checkSelfPermission before requesting).

Upvotes: 2

Related Questions