Tag:权限android
Article From:https://segmentfault.com/q/1010000012147798
Question:

How do you get permission details? Does Android have this API?
For example, pass a “android.permission.ACCESS_FINE_LOCATION” return name “location” and permission interpretation “to locate your mobile phone through a network or satellite.”
I feel that I have written trouble, maybe I can’t find the Android API document.

Answer 0:

Obviously there is such a API:PermissionInfo
Use the following code as an example of kotlin.

        val permissionInfo =  packageManager.getPermissionInfo("android.permission.ACCESS_FINE_LOCATION", PackageManager.GET_META_DATA)
        val desc = permissionInfo.loadDescription(packageManager)
        val label = getString(permissionInfo.labelRes)
        println("name:${permissionInfo.name}")
        println("desc:${desc}")
        println("label:${label}")

The output is as follows: (because I ran under the simulator, the default is English).

11-25 03:42:07.604 I/System.out: name:android.permission.ACCESS_FINE_LOCATION
11-25 03:42:07.604 I/System.out: desc:This app can get your location based on GPS or network location sources such as cell towers and Wi-Fi networks. These location services must be turned on and available on your phone for the app to be able to use them. This may increase battery consumption.
11-25 03:42:07.605 I/System.out: label:access precise location (GPS and network-based)

Answer 1:

There should be no similar API, because the definition of a permission itself does not contain much content and details.

Similar Posts:

Link of this Article: Android rights issue

Leave a Reply

Your email address will not be published. Required fields are marked *