0

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?

Ripei
  • 432
  • 2
  • 8
  • 19

3 Answers3

2

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.

Community
  • 1
  • 1
Roman Nurik
  • 29,665
  • 7
  • 84
  • 82
  • 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 Dec 23 '09 at 13:29
  • 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 Jan 07 '10 at 09:15
0

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
  • 24,780
  • 14
  • 77
  • 112
0

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
  • 9,553
  • 7
  • 48
  • 66