给定权限名称后,如何找到PermissionGroup? [英] Given a permission name, how do I find the PermissionGroup?

查看:347
本文介绍了给定权限名称后,如何找到PermissionGroup?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在运行时查找权限组的权限(以在UI中提供有关如何访问设置"的指南,然后在用户选中提示上的不再询问"按钮后启用该权限) .因此,我需要权限组的可读名称,但我所拥有的只是机器可读的标准权限字符串(Manifest.permission.READ_PHONE_STATE).有办法吗?

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?

推荐答案

getPermissionInfo()返回PermissionInfo. PermissionInfo具有一个group字段,其中包含组名("android.permission-group.CALENDAR",又名Manifest.permission_group.CALENDAR).

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()返回该组名的PermissionGroupInfo.然后,调用loadLabel(),并提供PackageManager作为输入,以获取权限组的可读名称.

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.

这篇关于给定权限名称后,如何找到PermissionGroup?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆