简体   繁体   English

CWAC相机显示黑屏,并且在拍照时应用程序崩溃

[英]CWAC Camera shows a black blank screen and application crashes while taking picture

All, 所有,

I am using the CWAC-Camera-v9 library in my application. 我在我的应用程序中使用CWAC-Camera-v9库。

I am seeing a blank screen while the camera launched and the application crashes while taking picture with below error message. 相机启动时出现空白屏幕,同时出现以下错误消息拍照时应用程序崩溃。

09-24 18:40:08.915: D/PortraitCameraActivity(24228): [DEBUG] Camera takePicture
09-24 18:40:08.920: D/AndroidRuntime(24228): Shutting down VM
09-24 18:40:08.920: W/dalvikvm(24228): threadid=1: thread exiting with uncaught exception (group=0x410f92a0)
09-24 18:40:08.925: D/VM Util(24228): Preview mode must have started before you can take a picture
09-24 18:40:08.925: D/VM Util(24228): java.lang.IllegalStateException: Preview mode must have started before you can take a picture
09-24 18:40:08.925: D/VM Util(24228):   at com.commonsware.cwac.camera.CameraView.takePicture(CameraView.java:330)
09-24 18:40:08.925: D/VM Util(24228):   at com.commonsware.cwac.camera.CameraFragment.takePicture(CameraFragment.java:162)
09-24 18:40:08.925: D/VM Util(24228):   at android.view.View.performClick(View.java:4211)
09-24 18:40:08.925: D/VM Util(24228):   at android.view.View$PerformClick.run(View.java:17267)
09-24 18:40:08.925: D/VM Util(24228):   at android.os.Handler.handleCallback(Handler.java:615)
09-24 18:40:08.925: D/VM Util(24228):   at android.os.Handler.dispatchMessage(Handler.java:92)
09-24 18:40:08.925: D/VM Util(24228):   at android.os.Looper.loop(Looper.java:137)
09-24 18:40:08.925: D/VM Util(24228):   at android.app.ActivityThread.main(ActivityThread.java:4898)
09-24 18:40:08.925: D/VM Util(24228):   at java.lang.reflect.Method.invokeNative(Native Method)
09-24 18:40:08.925: D/VM Util(24228):   at java.lang.reflect.Method.invoke(Method.java:511)
09-24 18:40:08.925: D/VM Util(24228):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
09-24 18:40:08.925: D/VM Util(24228):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
09-24 18:40:08.925: D/VM Util(24228):   at dalvik.system.NativeStart.main(Native Method)

Any pointers will be really helpful. 任何指针将非常有帮助。

EDIT The test device is Samsung Galaxy S3 GT-I9300. 编辑测试设备为Samsung Galaxy S3 GT-I9300。 The camera in the native application works fine. 本机应用程序中的相机可以正常工作。

What i am trying to do is to use the camera library in a cross-platform tool called Kony. 我想做的是在称为Kony的跨平台工具中使用相机库。 Kony compiles and integrates the library without any issues. Kony可以毫无问题地编译和集成库。 But while launching the camera, i am seeing this issue. 但是在启动相机时,我看到了这个问题。

May i know the probable conditions at which the Camera fails to load. 我可以知道相机无法加载的可能情况。

I am trying to launch the MainActivity in the CameraDemo-V9 sample as below 我正在尝试在CameraDemo-V9示例中启动MainActivity,如下所示

Intent myIntent = new Intent(CamTestActivity.this, com.commonsware.cwac.camera.acl.demo.MainActivity.class);
this.startActivity(myIntent);

This sample is working expected in a Android native project. 该示例可在Android本机项目中正常工作。

-- Thanks, Sunil -谢谢苏尼尔

In terms of the exception, you are taking a picture before the preview has been set up, based upon the error message. 在例外情况下,您会根据错误消息在设置预览之前拍照。

In terms of the black screen, off the top of my head I do not know what might cause that. 在黑屏方面,我不知道是什么原因造成的。 Try running one of the demo apps and see if it behaves properly. 尝试运行其中一个演示应用程序,并查看其运行是否正常。 If it does not, there may be some incompatibility between the library and your device, in which case I would need to know the specifics of what device you have. 如果不是,则库与您的设备之间可能存在某些不兼容,在这种情况下,我需要了解所拥有设备的详细信息。 If the demo app works, presumably there is something that you are missing in the setup, and so you might compare your code with that of the demo app. 如果演示应用程序正常运行,则可能是您的设置中缺少某些内容,因此您可以将代码与演示应用程序的代码进行比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM