kevalpatel2106/android-hidden-camera

Always Error Null Pointer After Application Resume

depri opened this issue · 1 comments

depri commented

hello @kevalpatel2106 I got some problem here, I always got this error when my apps got onResume, I used version 1.3.1

FATAL EXCEPTION: main
java.lang.NullPointerException: Attempt to invoke virtual method 'android.hardware.Camera$Parameters android.hardware.Camera.getParameters()' on a null object reference
at com.androidhiddencamera.CameraPreview.surfaceChanged(CameraPreview.java:87)
at android.view.SurfaceView.updateWindow(SurfaceView.java:590)
at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:238)
at android.view.View.dispatchWindowVisibilityChanged(View.java:8697)
at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1269)
at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1269)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1311)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)

@depri Thank you for reporting this issue. I changed the behaviour of the HiddenCameraFragment.java and HiddenCameraActivity.java. Now both releases the camera on onPause() of the activity/fragment.

As I think there is no point to keep acquiring camera if while the app is in the background. If the application wants to capture an image while the app is in the background, it can use HiddenCameraService.java for that.

I made changes in latest sample apk and it doesn't crash now. You can check and report me back if the issue still exists.