Single intent to let user take picture OR pick image from gallery in Android

Posted by Damian on Stack Overflow See other posts from Stack Overflow or by Damian
Published on 2010-04-25T12:07:06Z Indexed on 2010/04/25 12:13 UTC
Read the original article Hit count: 310

Filed under:
|
|
|
|

I'm developing an app for Android 2.1 upwards. I want to enable my users to select a profile picture within my app (I'm not using the contacts framework).

The ideal solution would be to fire an intent that enables the user to select an image from the gallery, but if an appropriate image is not available then use the camera to take a picture (or vice-versa i.e. allow user to take picture but if they know they already have a suitable image already, let them drop into the gallery and pick said image).

Currently I can do one or the other but not both.

If I go directly into camera mode using MediaStore.ACTION_IMAGE_CAPTURE then there is no option to drop into the gallery.

If I go directly to the gallery using Intent.ACTION_PICK then I can pick an image but if I click the camera button (in top right hand corner of gallery) then a new camera intent is fired. So, any picture that is taken is not returned directly to my application. (Sure you can press the back button to drop back into the gallery and select image from there but this is an extra unnecessary step and is not at all intuitive).

So is there a way to combine both or am I going to have to offer a menu to do one or the other from within my application? Seems like it would be a common use case...surely I'm missing something?

© Stack Overflow or respective owner

Related posts about android

Related posts about camera