kevalpatel2106 / android-hidden-camera

This library is to take picture using camera without camera preview.
Apache License 2.0
408 stars 155 forks source link

Good day. I dont know why my app crashes when I add hidden camera through background service. The fragment that uses hidden camera starts using a "new Thread()" approach. :( thanks. #15

Open pastillas opened 7 years ago

pastillas commented 7 years ago

FATAL EXCEPTION: main java.lang.RuntimeException: startPreview failed at android.hardware.Camera.startPreview(Native Method) at com.androidhiddencamera.CameraPreview.surfaceChanged(CameraPreview.java:128) at android.view.SurfaceView.updateWindow(SurfaceView.java:626) at android.view.SurfaceView.access$000(SurfaceView.java:86) at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:178) at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:707) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1938)at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4454) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) at android.view.Choreographer.doCallbacks(Choreographer.java:555) at android.view.Choreographer.doFrame(Choreographer.java:525)at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711) at android.os.Handler.handleCallback(Handler.java:615) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4895) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511)at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761) at dalvik.system.NativeStart.main(Native Method)

kevalpatel2106 commented 7 years ago

@pastillas Can you provide the source code?

jom16antonio commented 7 years ago

use Handler, instead of Thread

kevalpatel2106 commented 7 years ago

@jom16antonio Thanks. Let me try.