Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
577 views
in Technique[技术] by (71.8m points)

android - Given a permission name, how do I find the PermissionGroup?

I want to look up the permission group for a permission at runtime (to provide guidance in the UI about how to visit Settings and then enable the permission, after the user has checked the "never ask again" button on the prompt). So I need the human-readable name for the permission group, but all I have is the machine-readable fully qualified permission string (Manifest.permission.READ_PHONE_STATE). Is there a way to do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

getPermissionInfo() on PackageManager returns a PermissionInfo given the name of the permission. PermissionInfo has a group field that contains the group name ("android.permission-group.CALENDAR", a.k.a. Manifest.permission_group.CALENDAR).

getPermissionGroupInfo() on PackageManager returns a PermissionGroupInfo for that group name. On that, call loadLabel(), supplying the PackageManager as input, to get the human-readable name of the permission group.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...