0

All,

I am using the CWAC-Camera-v9 library in my application.

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. 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 compiles and integrates the library without any issues. 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

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.

-- Thanks, Sunil

sunil
  • 6,444
  • 1
  • 32
  • 44
  • possible duplicate of [Preview mode must have started before you can take a picture](http://stackoverflow.com/questions/24456715/preview-mode-must-have-started-before-you-can-take-a-picture) – Marlon Sep 30 '14 at 07:42

1 Answers1

1

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • @sunil: Sorry, but I do not know what to tell you. Perhaps Kony does not hold the proper permissions. Note that your explanation and your stack trace do not match, as your stack trace does not come from `com.commonsware.cwac.camera.acl.demo.MainActivity`. – CommonsWare Sep 30 '14 at 10:55
  • You are right. I was using a third party library in which your camera has been used. I faced this issue. The trace was from that application. So, tried to invoke your sample activity from another activity. Again the same issue. The issue got resolved when i enabled the hardwareAccelerated flag for the activity in which the camera is used. Thanks for your help. Do you see any issue in enabling hardwareAccelerated flag for an activity ? – sunil Oct 01 '14 at 14:54