Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

java.lang.NullPointerException on samsung SM-G9550 #257

Open
Lans opened this issue Sep 14, 2018 · 5 comments
Open

java.lang.NullPointerException on samsung SM-G9550 #257

Lans opened this issue Sep 14, 2018 · 5 comments

Comments

@Lans
Copy link

Lans commented Sep 14, 2018

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.hardware.camera2.CameraCaptureSession.capture(android.hardware.camera2.CaptureRequest, android.hardware.camera2.CameraCaptureSession$CaptureCallback, android.os.Handler)' on a null object reference
at com.google.android.cameraview.Camera2.unlockFocus(TbsSdkJava:662)
at com.google.android.cameraview.Camera2$6.onCaptureCompleted(TbsSdkJava:646)
at java.lang.reflect.Method.invoke(Native Method)
at android.hardware.camera2.dispatch.InvokeDispatcher.dispatch(InvokeDispatcher.java)
at android.hardware.camera2.dispatch.HandlerDispatcher$1.run(HandlerDispatcher.java)
at android.os.Handler.handleCallback(Handler.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)

@kraa
Copy link

kraa commented Sep 19, 2018

Same on Samsung Galaxy A8 SM-A530F

It happens because CameraView stop called earlier then unlockFocus

@Lans
Copy link
Author

Lans commented Sep 19, 2018

Same on Samsung Galaxy A8 SM-A530F

It happens because CameraView stop called earlier then unlockFocus

how to solve it

@kraa
Copy link

kraa commented Sep 19, 2018

I don't look for reason of that.. You need to delay cameraview stop. The straight-forward solution is simply call stop (that you do after cameraview captured image) with delay like
new Handler().postDelayed(() -> cameraView.stop(), 200);

It's fast but ugly solution.

@Lans
Copy link
Author

Lans commented Sep 20, 2018

I don't look for reason of that.. You need to delay cameraview stop. The straight-forward solution is simply call stop (that you do after cameraview captured image) with delay like
new Handler().postDelayed(() -> cameraView.stop(), 200);

It's fast but ugly solution.

I don't look for reason of that.. You need to delay cameraview stop. The straight-forward solution is simply call stop (that you do after cameraview captured image) with delay like
new Handler().postDelayed(() -> cameraView.stop(), 200);

It's fast but ugly solution.

After samsung's camera is called, the system will call ondestroy and the activity will be destroyed and rebuilt, because the system calls a horizontal and vertical switch

<activity
        android:name=".activity.CameraActivity"
        android:configChanges="orientation|keyboardHidden"
        android:launchMode="singleTop"
        android:screenOrientation="portrait"
        android:theme="@style/AppThemeNoBackground" />

You can try this

@jjn2004
Copy link

jjn2004 commented Nov 27, 2018

anyone has the final solution? we meet it on HUAWEI 8.0.0 phone

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants