Im trying to fix this issue simillar like this: https://github.com/google/cameraview/issues/29 , which is probably caused by finishing activity too early after picture was taken.
My idea was to properly close CameraView after picture was taken before finishing activity. But anyway Im trying to close camera in onPictureTakenCallback i get this error:
Fatal Exception: java.lang.RuntimeException: Camera is being used after Camera.release() was called
at android.hardware.Camera.native_cancelAutoFocus(Camera.java)
at android.hardware.Camera.cancelAutoFocus(Camera.java:1383)
at com.google.android.cameraview.Camera1$3.onPictureTaken(Camera1.java:246)
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1170)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5569)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:931)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:726)
Im trying to fix this issue simillar like this: https://github.com/google/cameraview/issues/29 , which is probably caused by finishing activity too early after picture was taken. My idea was to properly close CameraView after picture was taken before finishing activity. But anyway Im trying to close camera in onPictureTakenCallback i get this error:
Here is code: