try { cameraManager.openDriver(surfaceHolder); // Creating the handler starts the preview, which can also throw a // RuntimeException. if (handler == null) { handler = new CaptureActivityHandler(this, cameraManager, scanMode); Log.e("hongliang1", "handler new成功!:" + handler); } initCrop(); } catch (Exception ioe) { Log.e(TAG, "hongliang", ioe); //弹出提示,报错 ioe.printStackTrace(); listener.scanError(new Exception("相机打开出错,请允许该权限的获取!")); requestMultiplePermissions(); }
@TargetApi(Build.VERSION_CODES.M) private void requestMultiplePermissions() {
//此数组放权限列表,以摄像头权限为例 String[] permissions = {Manifest.permission.CAMERA}; activity.requestPermissions(permissions, REQUEST_CODE); }