Closed mskocabay closed 6 years ago
The PhotographerActivity.onPause()
method stops the camera and background tasks for you:
So if you have kept the onPause()
implementation, then there is no need to do it anymore.
Thank you very much , it is best camera2 example. I tried it but returns this error in andoid 6
FATAL EXCEPTION: main Process: arge.aa.com.myapplication, PID: 10109 java.lang.RuntimeException: Unable to pause activity {com.camera.myapplication/arge.aa.com.myapplication.PhotographerActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean
and in android 8
FATAL EXCEPTION: main Process: arge.aa.com.myapplication, PID: 19986 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.os.Handler.post(java.lang.Runnable)' on a null object reference at arge.aa.com.myapplication.Camera2Photographer$4.onImageAvailable(Camera2Photographer.java:195) at android.media.ImageReader$ListenerHandler.handleMessage(ImageReader.java:812) at android.os.Handler.dispatchMessage(Handler.java:108) at android.os.Looper.loop(Looper.java:166) at android.app.ActivityThread.main(ActivityThread.java:7425) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)
Seems that the onShotFinished()
is called too early, and the image is not finished saving at that time:
then when the ImageSaver
try to save the image, the backgroundHandler
has been set to null by onPause()
:
I think we could try to put the event:
after:
@mskocabay I'm sorry I have no enough time to debug this issue, could you please try to solve this by your own and it's much better if you can create a pull request if applicable.
ok thank you very much
After completed camera operations , I want to show image or video in other actvity . Is that true ?
In PhotographerActivity.java i added to announcingNewFile method these codes. Is it enogh or must i do something about stop camera or backgroundtasks?
Thank you