Android Intent保存路径
目前我正在使用两个意图。一个用于录音,另一个用于相机:
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);
我的目标是为每个包含存储图片/录制的语音的路径添加一个额外的内容。有这样做的选择吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
EXTRA_OUTPUT
额外项为使用ACTION_IMAGE_CAPTURE
拍摄的图像指定目标 Uri(但不能使用RECORD_SOUND_ACTION
;为此,返回的捆绑包将包含文件路径)。可以在此处找到示例,摘录如下:
松散地引用yanokwa:
顺便说一句,可以在此处找到类似的问题。
You can use the
EXTRA_OUTPUT
extra to specify a destination Uri for images taken withACTION_IMAGE_CAPTURE
(but notRECORD_SOUND_ACTION
; for that, the returned bundle will contain the file path).An example can be found here, excerpt below:
Loosely quoting yanokwa:
BTW, a similar question can be found here.
我不确定,但我的第一个想法是设置意图的数据 uri,看看是否有任何作用。
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.