首页 > 代码库 > android判断应用是否有某个权限

android判断应用是否有某个权限

1) 判断应用是否具有某个权限PackageManager pm = getPackageManager();        boolean permission = (PackageManager.PERMISSION_GRANTED ==                 pm.checkPermission("android.permission.RECORD_AUDIO", "packageName"));        if (permission) {            showToast("有这个权限");        }else {            showToast("木有这个权限");        }2)获取某个应用的权限清单try {            PackageInfo pack = pm.getPackageInfo("packageName",PackageManager.GET_PERMISSIONS);</span>            String[] permissionStrings = pack.requestedPermissions;            showToast("权限清单--->" + permissionStrings.toString());        } catch (NameNotFoundException e) {            e.printStackTrace();        }permissionStrings 是一个这样的字符串数组[android.permission.INTERNET,          android.permission.READ_PHONE_STATE,          android.permission.READ_CONTACTS,          ……         android.permission.READ_EXTERNAL_STORAGE,          android.permission.READ_CALL_LOG,          android.permission.WRITE_CALL_LOG]

 

android判断应用是否有某个权限