Android:获取本地化的权限组名称 [英] Android: Get localized permission group names

本文介绍了Android:获取本地化的权限组名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在棉花糖的运行时权限中,用户可以在权限请求中选择不再询问".在这种情况下,我们必须将用户重定向到应用程序设置,以使他们启用应用程序的权限.另外,Android权限是基于组的,在我们将用户发送到设置之前,显示应用所需的权限组的名称将非常方便.

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.

我在 android.Manifest 中看到了字符串,例如" android.permission-group.LOCATION ".是否可以通过编程获取权限组名称?

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

推荐答案

getPermissionGroupInfo()返回该组名(android.permission-group.LOCATION)的PermissionGroupInfo.在此之后,调用loadLabel(),并提供PackageManager作为输入,以获取权限组的可读名称.应该针对用户选择的设备区域设置进行本地化.

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.

这篇关于Android:获取本地化的权限组名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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