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

问题描述

requestedPermissionspermissions有什么区别?

PackageInfo _pi = getPackageManager().getPackageInfo(this.getPackageName(), 
                                               PackageManager.GET_PERMISSIONS);

// permissions
PermissionInfo[] _permissions = _pi.permissions;

// requestedPermissions
String[] _requestedPermissions = _pi.requestedPermissions;

与应用程序的权限和操作系统的权限有关吗?

Is it about application's permissions and OS's permissions?

谢谢

推荐答案

与文档中一样

<manifest>下包含的所有<permission>标签的数组,如果为null,则为null 没有.

Array of all <permission> tags included under <manifest>, or null if there were none.

<manifest>下包含的所有<uses-permission>标签的数组,或者为null 如果没有的话.

Array of all <uses-permission> tags included under <manifest>, or null if there were none.

因此permissionInfo将在清单中的manifest标记中具有attributes,例如

so permissionInfo will have the attributes in manifest tag in manifest for e.g.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.androidtest"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name">

requstedPermissions将在<uses-permission>标签中返回权限,例如

requstedPermissions will return the permissions in <uses-permission>tag for e.g

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />

这篇关于PackageInfo:requestedPermissions与权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 22:09