views:

493

answers:

3

Hey Guys

At the moment I am using two intents. One for voice-recording, another for the camera:

Intent photoIntent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(photoIntent, ACTIVITY_TAKE_PHOTO);

Intent voiceIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
startActivityForResult(voiceIntent, ACTIVITY_RECORD_SOUND);

My aim is to put an Extra to each of those which contains the path where to store the picture / the recorded Voice. Is there an option to do so?

A: 

I am not sure but my first thought would be to set the data uri of the intent and see if that does anything.

CaseyB
A: 

AFAIK this is not possible from firing off Intents.

When the given activity returns the picture/voice data should be in the result. Take that data and then save it from within your activity to your desired location. The camera/recorder activity simply handles pictures/audio and then returns the result back to you to handle.

Donn Felker
+2  A: 

You can use the EXTRA_OUTPUT extra to specify a destination Uri for images taken with ACTION_IMAGE_CAPTURE (but not RECORD_SOUND_ACTION; for that, the returned bundle will contain the file path).

An example can be found here, excerpt below:

Loosely quoting yanokwa:

// fire off the intent
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
           Uri.fromFile(new File("<temp file path here>")));
startActivityForResult(i, mRequestCode);

BTW, a similar question can be found here.

Roman Nurik
thanks very much for this solution... this is the code i was looking for. but when testing this i ran into the same problem, which the person in the link had. the camera activity does nothing when i click on the "ok"button. as described in the link the camera-apps seems to have no write-permissions. isn't there any solution to this issue, except rewriting the camera-app?
Ripei
ok i now tried it on the htc hero (before i used the emulator). i figured out that the photo is normally viewable via the media-app. in other words: the photo is saved to the normal photo-directory. and the EXTRA.OUTPUT has no effect. any ideas why?!
Ripei