如何删除使用 ACTION_VIDEO_CAPTURE 的 Intent 录制的视频?
我想删除之前使用 Intent 录制的视频:
Intent captureVideoIntent = new Intent(
android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(captureVideoIntent, VIDEO_CAPTURED);
方法 onActivityResult() 将录制的视频作为 Intent 数据获取。我尝试获取录制的文件并将其删除。
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Code for modify and copy the video
try {
Uri androidUri = data.getData();
File file = new File(new java.net.URI(androidUri.toString()));
file.delete();
} catch (Exception e) {
e.printStackTrace();
}
}
但我收到错误:
java.lang.IllegalArgumentException:URI 中的预期文件方案:content://media/external/video/media/177。
有人知道如何获取录制视频的路径并移动或删除它吗?
I would like to remove a video that has been previously recorded using an Intent:
Intent captureVideoIntent = new Intent(
android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(captureVideoIntent, VIDEO_CAPTURED);
The method onActivityResult() get the recorded video as Intent data. I try to obtain the recorded file and delete it.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Code for modify and copy the video
try {
Uri androidUri = data.getData();
File file = new File(new java.net.URI(androidUri.toString()));
file.delete();
} catch (Exception e) {
e.printStackTrace();
}
}
But I get the error:
java.lang.IllegalArgumentException: Expected file scheme in URI: content://media/external/video/media/177.
Does somebody know how can I get the path of the recorded video and move or delete it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个答案如何从内容 URI。您应该能够将其结果传递给
File
构造函数。This answer has how to get the path from a content URI. You should be able to pass its result to the
File
constructor.