Android的MediaStore insertVideo [英] Android MediaStore insertVideo

查看:732
本文介绍了Android的MediaStore insertVideo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我们的应用程序有选择采取任何图片或视频。如果用户需要的图片,我们可以使用MediaStore.Images.Media.insertImage功能来添加新的图像(通过文件路径)到手机的相册,并生成内容://风格的URI。是否有一个类似的过程中捕捉的视频,因为我们只有它的文件路径?

So our app has the option to take either a picture or a video. If the user takes a picture, we can use the MediaStore.Images.Media.insertImage function to add the new image (via a filepath) to the phone's gallery and generate a content:// style URI. Is there a similar process for a captured video, given that we only have it's filepath?

推荐答案

下面是一个简单的单个文件的解决方案:

Here is an easy 'single file based solution':

每当您添加一个文件,让MediaStore内容提供商知道它使用

Whenever you add a file, let MediaStore Content Provider knows about it using

sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(imageAdded)));

主要优点:与MediaStore支持的MIME类型的工作

Main advantage: work with any mime type supported by MediaStore

对于删除:只需使用getContentResolver()删除(URI,NULL,NULL)

For deletion: just use getContentResolver().delete(uri, null, null)

这篇关于Android的MediaStore insertVideo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆