views:

102

answers:

1

I want my Android app to take a picture, as part of something larger it is doing.

Ideally, I would like to just send out an Intent saying "snap a picture" and get back an image file.

Is there an Activity that can handle that, or do I need to do all the low level work with the Camera class myself?

Thanks,

Peter

+4  A: 

You can invoke the default camera activity using an Intent and startActivityForResult(). You can also construct a Uri and file name for the image and pass that to the photo capture activity. When the user takes a photo it will be saved with that name at the location you've specified.

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
intent.putExtra( MediaStore.EXTRA_OUTPUT, outputUri );
startActivityForResult( intent, 0 );

If the user cancels the capture then a result of 0 is returned, and if they take a photo and approve it, a result of -1 is returned.

jeremynealbrown
Answering this question inspired me to write a quick tutorial on using the built in Android Camera app:http://labs.makemachine.net/2010/03/simple-android-photo-capture/
jeremynealbrown
That is very helpful, Jeremy - thanks!
Peter vdL