问题描述
我们正在这样的踪迹在我们的应用程序中使用CWAC相机:
java.lang.IllegalStateException:preVIEW模式必须开始之前,你可以拍照
在com.commonsware.cwac.camera.CameraView.takePicture(CameraView.java:329)
在com.commonsware.cwac.camera.CameraView.takePicture(CameraView.java:277)
在com.github.randoapp.camera.RandoCameraHost.onAutoFocus(RandoCameraHost.java:119)
在com.commonsware.cwac.camera.CameraView.onAutoFocus(CameraView.java:411)
在android.hardware.Camera $ EventHandler.handleMessage(Camera.java:824)
在android.os.Handler.dispatchMessage(Handler.java:99)
在android.os.Looper.loop(Looper.java:137)
在android.app.ActivityThread.main(ActivityThread.java:4898)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:511)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1008)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
在dalvik.system.NativeStart.main(本机方法)
我们认为,这可以happenning因为用户pressing拍摄照片为时尚早。解决的办法是禁用按钮,preVIEW初始化并启用只有当它这样做。现在的问题是:使用按钮启用哪些事件?是否有事件或回调sayong是preVIEW终于初始化?
这是一个明显的可能性。
autoFocusAvailable()
在 CameraHost
是最好的时刻选择。这就是所谓的preVIEW开始,在preVIEW之前
设置为真
。
我已经申请问题做一个更好的工作莫过于此。
We are getting such stacktraces in our application using cwac-camera:
java.lang.IllegalStateException: Preview mode must have started before you can take a picture
at com.commonsware.cwac.camera.CameraView.takePicture(CameraView.java:329)
at com.commonsware.cwac.camera.CameraView.takePicture(CameraView.java:277)
at com.github.randoapp.camera.RandoCameraHost.onAutoFocus(RandoCameraHost.java:119)
at com.commonsware.cwac.camera.CameraView.onAutoFocus(CameraView.java:411)
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:824)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
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:1008)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
at dalvik.system.NativeStart.main(Native Method)
We believe that this can be happenning because of users pressing take picture too early. The solution is to disable button while preview is initializing and enable only when it's done. The question is: What event to use for button enabling? Is there event or callback sayong that preview is finally initialized?
That is a distinct possibility.
autoFocusAvailable()
in your CameraHost
is the best option at the moment. That is called just before the preview begins and inPreview
is set to true
.
I have filed an issue to do a better job than this.
这篇关于preVIEW模式必须开始之前,你可以拍照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!