使用Camera2开发照相机功能,可以进行重复拍照,刚开始拍照是好的,但是重复拍照的时候就会报错如下,有时候第一次拍照就报错,有时候拍了几十张后报错,报错就是闪退
E/AndroidRuntime: FATAL EXCEPTION: LegacyCameraCallback
Process: com.ajmd.hais.mobile, PID: 24711
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Surface android.hardware.camera2.params.OutputConfiguration.getSurface()' on a null object reference
at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.onCaptureErrorLocked(CameraDeviceImpl.java:1925)
at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.onDeviceError(CameraDeviceImpl.java:1693)
at android.hardware.camera2.legacy.CameraDeviceUserShim$CameraCallbackThread$CallbackHandler.handleMessage(CameraDeviceUserShim.java:299)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
来源:CSDN
作者:zf_1021042350
链接:https://blog.csdn.net/zf_1021042350/article/details/103616837