判断和检查app应用是否具有某个权限

判断应用是否具有某个权限
一.判断应用是否具有某个权限
PackageManager pm = getPackageManager();
boolean permission = (PackageManager.PERMISSION_GRANTED ==
pm.checkPermission(“android.permission.RECORD_AUDIO”, “packageName”));
if (permission) {
showToast(“有这个权限”);
}else {
showToast(“木有这个权限”);
}
二.获取某个应用的权限清单

PackageInfo pack =pm.getPackageInfo(“packageName”,PackageManager.GET_PERMISSIONS);
String[] permissionStrings = pack.requestedPermissions;

你可能感兴趣的:(判断和检查app应用是否具有某个权限)