So this is kinda funky. If you want to take a picture on Android with the Camera you have to first create a preview surface. Seems like a bad design to me, but I don’t make the rules here. So according to the documentation you are required to call
startPreview() first before calling
takePicture() But what if you don’t want a preview and just want to take a picture? Well you can just create a dummy SurfaceView for the purposes of the preview and then let the garage collector grab it when you’re done. Here’s the snippet:
SurfaceView view = new SurfaceView(this);
c.takePicture(shutterCallback, rawPictureCallback, jpegPictureCallback);
Update 12/6/11: Looks like this doesn’t work for every camera, I’ve added a table here summarizing the comments people have made. If you have any more to add, please send a comment for this post.
|Samsung Galaxy S||2.2||Yes|
|Samsung Galaxy Note||2.3.6||No|