不可行权限判断API:
context.checkCallingPermission
context.checkCallingOrSelfPermission
context.checkSelfPermission
PermissionChecker.checkSelfPermission
使用Camera中的mHasPermission
private boolean cameraHasPermission(Camera camera) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.M){
Class clazz = Class.forName(camera.getClass().getCanonicalName());Field mHasPermission = clazz.getDeclaredField("mHasPermission");mHasPermission.setAccessible(true);return mHasPermission.getBoolean(camera);}
}
网友评论