Search code examples
permissionsandroid-10.0

queryPermissionsByGroup return null on android Q


I need to use Camera permission in my app. The code use PackageManager.queryPermissionsByGroup to query permission in "android.permission-group.CAMERA" group.

I found in android Q, this method return null. But found no detailed explanation about how to replace this.

Anyone know about the detailed change about query permissions in a permission-group in android Q, and how to correct in this version?


Solution

  • This is mentioned in the release notes:

    As of Android Q, apps cannot look up how permissions are grouped in the UI.

    You would need to collect that information manually and encode it in your app. For example, here is the platform manifest from Q Beta 5. If you manually search for android:permissionGroup="android.permission-group.CAMERA", you will see that the only permission in that group is android.permission.CAMERA. If in some future version of Android, other permissions are added to that group, you would find that in the platform manifest and would be able to update your app. While this approach does not take into account any manufacturer-specific changes, I suspect it is the only workaround.