nisrulz / qreader

:white_square_button: [Android Library] Read QR codes using google's mobile vision api, but without the hassle
http://nisrulz.github.io/qreader
Apache License 2.0
371 stars 108 forks source link

java.lang.IllegalStateException: Camera already started! #56

Open lakshyapunhani opened 6 years ago

lakshyapunhani commented 6 years ago

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.shanky.qrscanner, PID: 8249 java.lang.IllegalStateException: Camera already started! at github.nisrulz.qreader.QREader.startCameraView(QREader.java:213) at github.nisrulz.qreader.QREader.start(QREader.java:176) at github.nisrulz.qreader.QREader$2.onGlobalLayout(QREader.java:118) at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:981) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2414) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1522) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7098) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:927) at android.view.Choreographer.doCallbacks(Choreographer.java:702) at android.view.Choreographer.doFrame(Choreographer.java:638) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:913) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6682) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

This happens when application goes in paused state while scanning qr code and just resume the application it will crash

This is the code for paused state and resume state

@Override protected void onPause() { super.onPause();

    if (hasCameraPermission) {

        // Cleanup in onPause()
        // --------------------
        qrEader.releaseAndCleanup();
    }
}

@Override
protected void onResume() {
    super.onResume();

    if (hasCameraPermission) {

        // Init and Start with SurfaceView
        // -------------------------------
        qrEader.initAndStart(mySurfaceView);

    }
}
riyal123 commented 5 years ago

any update on this?

khaled-qasem commented 4 years ago

@nisrulz Any updates?

nisrulz commented 4 years ago

@khaled-qasem

Please read my comment here: https://github.com/nisrulz/qreader/issues/68#issuecomment-576261126