0

Is there I way to check if some specific permission-group is granted or not, lets say android.permission-group.CONTACTS for example? Contacts group have three permissions: android.permission.READ_CONTACTS , android.permission.WRITE_CONTACTS and android.permission.GET_ACCOUNTS.

So if I want to check if one of these permission is granted I would use this code bellow, where permisssionKey would be one of three Contacts permissions.

boolean isGranted=checkSelfPermission(permisssionKey)==PackageManager.PERMISSION_GRANTED;

But is it possible to check if android.permission-group.CONTACTS (or some other permission-group) is granted or not, not just one of their permissions, just as shown on the image?

enter image description here

alezniki
  • 185
  • 1
  • 14
  • Possible duplicate of [How i can request permission at runtime in Android?](https://stackoverflow.com/questions/37441133/how-i-can-request-permission-at-runtime-in-android) – Thomas Mary Apr 11 '18 at 19:04
  • Hi Thomas, it is not duplicate, I need to check if grouped permission is granted, not to request single permission. – alezniki Apr 11 '18 at 19:10

1 Answers1

0

Is there I way to check if some specific permission-group is granted or not

No, sorry.

While the current UX has the user only granting permissions at the group level, the API is set up for permissions to be granted at the permission level. Presumably, this provides flexibility, should Google elect to allow users to enable/disable individual permissions within the group in the future.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks CommonsWare, is there any alternative way to check if permissions are enabled/disabled for specific group? – alezniki Apr 11 '18 at 19:18
  • @alezniki: Iterate over the permissions and find out the state of each individual one. You should be able to use [`queryPermissionsByGroup()`](https://developer.android.com/reference/android/content/pm/PackageManager.html#queryPermissionsByGroup(java.lang.String,%20int)) to find out what is in the group. Or, just worry about those permissions that you have listed in your manifest for that group. – CommonsWare Apr 11 '18 at 19:21