Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Get localized permission group names

In marshmallow's runtime permission, user can choose "never ask again" in permission requests. In this case, we have to redirect user to app settings to let them enable the permissions for the app. Also, Android permissions are group based, it will be very handy to display names of the permission groups that the app needs before we send the user to the settings.

I've seen the strings in android.Manifest such as "android.permission-group.LOCATION". Is it possible to get the permission group names programmatically?

like image 511
esong Avatar asked Nov 24 '15 17:11

esong


People also ask

What are permission groups in Android?

<permission-group>Members of a group are presented together in the user interface. Note that this element does not declare a permission itself, only a category in which permissions can be placed. See the <permission> element for element for information on declaring permissions and assigning them to groups.

What does READ_PHONE_STATE permission do?

Allows read only access to phone state, including the phone number of the device, current cellular network information, the status of any ongoing calls, and a list of any PhoneAccounts registered on the device. Used to determine the state of the mobile app. Jacob to provide additional details on exact functions.

What is Android permission Request_install_packages?

REQUEST_INSTALL_PACKAGES permission provides apps with the ability to install new packages on a user's device.


1 Answers

getPermissionGroupInfo() on PackageManager returns a PermissionGroupInfo for that group name (android.permission-group.LOCATION). On that, call loadLabel(), supplying the PackageManager as input, to get the human-readable name of the permission group. This should be localized for the user's chosen device locale.

like image 151
CommonsWare Avatar answered Sep 27 '22 18:09

CommonsWare