Closed ahmedmoussa8 closed 7 years ago
I have solved this issue by doing the following:
1 - Make the Visibility of QRCodeReaderView to GONE in XML.
2- For Android M: request for camera permission. then in onRequestPermissionsResult() show up the QRCodeReaderView to VISIBLE.
and add the view properties
mydecoderview = (QRCodeReaderView) mainLayout.findViewById(R.id.qrdecoderview); assert mydecoderview != null; mydecoderview.setOnQRCodeReadListener(this); mydecoderview.setAutofocusInterval(2000L); mydecoderview.setBackCamera(); mydecoderview.setVisibility(View.VISIBLE); mydecoderview.startCamera();
This really should be handled by the component.
java.lang.RuntimeException: Fail to connect to camera service at android.hardware.Camera.<init>(Camera.java:568) at android.hardware.Camera.open(Camera.java:405) at com.google.zxing.client.android.camera.open.OpenCameraInterface.open(OpenCameraInterface.java:76) at com.google.zxing.client.android.camera.CameraManager.openDriver(CameraManager.java:96) at com.dlazaro66.qrcodereaderview.QRCodeReaderView.surfaceCreated(QRCodeReaderView.java:183) at android.view.SurfaceView.updateWindow(SurfaceView.java:720) at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:215) at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:1014) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2603) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1528) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7564) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911) at android.view.Choreographer.doCallbacks(Choreographer.java:686) at android.view.Choreographer.doFrame(Choreographer.java:622) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:7331) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)