Android Intent Save Path
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(vo开发者_Go百科iceIntent, 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?
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.
I am not sure but my first thought would be to set the data uri of the intent and see if that does anything.
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.
精彩评论