问题
When my picture is taken via takePicture() function, Cwac-camera crash (depending device, work well on Desire HD, crash on Nexus S).
Referring to this post : camera.setParameters failed in android
I would like to know how to do this with Cwac-camera.
Backtrace:
07-03 20:58:57.207 24659-24659/com.xxxxxx E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: setParameters failed
at android.hardware.Camera.native_setParameters(Native Method)
at android.hardware.Camera.setParameters(Camera.java:1410)
at com.commonsware.cwac.camera.CameraView$OnOrientationChange.onOrientationChanged(CameraView.java:413)
at android.view.OrientationEventListener$SensorEventListenerImpl.onSensorChanged(OrientationEventListener.java:143)
at android.hardware.SystemSensorManager$ListenerDelegate$1.handleMessage(SystemSensorManager.java:204)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
回答1:
This crash is not coming from takePicture()
. If you look at the stack trace, you will not see takePicture()
. Instead, this is coming from an orientation change. Specifically, you appear to have the device locked to an orientation, causing CameraView
to use sensors to detect the device orientation to try to adjust the camera settings, and we're dying there.
If you can reproduce this problem with the demo app, please file an issue with the steps to reproduce it, as I cannot reproduce it on a Nexus S with the demo app.
If you cannot reproduce this problem with the demo app, and you can publish a reproducible test case, please file an issue with the source code to the reproducible test case.
Otherwise, you will have to hope that the problem that you are experiencing is related to this issue on switching cameras with the Nexus S, and then further hope that I can figure out what that problem is.
来源:https://stackoverflow.com/questions/17456247/cwac-camera-crash-when-picture-taken