3

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?

tainy
  • 951
  • 7
  • 19

1 Answers1

4

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.

Vlad
  • 7,997
  • 3
  • 56
  • 43
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thank you! So that I could not find permissions in a permission-group by code, so should we assume that the concept of permission-group is useless in android Q? And we have to request separate permissions one by one if we need it? – tainy Aug 04 '19 at 03:26
  • @tainy: "should we assume that the concept of permission-group is useless in android Q?" -- no. You just cannot look up the elements of the group. "And we have to request separate permissions one by one if we need it?" -- that has always been the expectation, and it has been required since 8.1 or 9.0 IIRC. – CommonsWare Aug 04 '19 at 11:08
  • @CommonsWare See you again here. How could we get the group name of a permission? so that I can show it to the users when they denied the permission and guide them to open it in the system setting – Zijian Jan 15 '20 at 04:07
  • @Zijian: As I mentioned to you [here](https://stackoverflow.com/questions/33899686/android-get-localized-permission-group-names/33899711?noredirect=1#comment105648502_33899711) a few seconds ago, I suspect that is no longer possible, based on your described symptoms and [this bug report](https://issuetracker.google.com/issues/139012029). – CommonsWare Jan 15 '20 at 12:07