获取应用所需权限(只能获取在AndroidManifest.xml文件中声明的权限,像手机设置-》权限管理-》应用-》权限列表这个里面的权限并不是都能获取,比如读取应用列表的权限就获取不到)
PackageInfo pkgInfo = packageManager.getPackageInfo(getPackageName(), PackageManager.GET_PERMISSIONS); String sharedPkgList[] = pkgInfo.requestedPermissions; StringBuilder sb = new StringBuilder(); for(int i=0;i<sharedPkgList.length;i++) { String permName = sharedPkgList[i]; PermissionInfo tmpPermInfo = packageManager.getPermissionInfo(permName, 0); sb.append(i + "-" + permName + "\n"); sb.append(i + "-" + tmpPermInfo.loadLabel(packageManager).toString() + "\n"); sb.append(i + "-" + tmpPermInfo.loadDescription(packageManager).toString() + "\n"); }
虽说READ_PHONE_STATE和CALL_PHONE属于同一个权限组