There are enough sites that help you to get a CameraPreview going. Most of them seem to be based on this resource from the apidemos.

If you implement this uncarefully, you might see this error, or something like it:

ERROR/AndroidRuntime(): Uncaught handler: thread main exiting due to uncaught exception
ERROR/AndroidRuntime(): java.lang.RuntimeException: Out of memory
ERROR/AndroidRuntime():     at android.hardware.Camera.native_setup(Native Method)
ERROR/AndroidRuntime():     at android.hardware.Camera.<init>(
ERROR/AndroidRuntime():     at

My google-fu was a bit off maybe, but the rather simple explanation took some time to find. There are some interesting discussion about the stopPreview() and release() function of the Camera class, but that wasn’t the basic problem in this case; here it is, in all its simplicity:

Add the camera permission to your manifest.

Yes. that simple. I’m not saying that fixes ALL of your problems, but I am saying that you’ll get problems if you don’t :)
I have no clue why you seem to get a memory error when the permissions are missing, but you do :)

This is the line you’re supposed to add tot the AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA"/>

Comments are closed.