美文网首页
Android 6.0以下摄像头权限

Android 6.0以下摄像头权限

作者: 407ed84abd35 | 来源:发表于2017-03-31 11:55 被阅读94次

不可行权限判断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);}

}

相关文章

网友评论

      本文标题:Android 6.0以下摄像头权限

      本文链接:https://www.haomeiwen.com/subject/ykzmottx.html