如何将文件转换:// URI到的内容:// URI? [英] How to convert a file:// uri into content:// uri?

查看:127
本文介绍了如何将文件转换:// URI到的内容:// URI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现我的设备上,默认的媒体显示工具不显示我,如果IHAVE的URI是相同的:

I have found that on my device, the default media display tool is not showing me the same if Ihave a uri that is:

file://mnt/sdcard/DCIM/Image.jpg

当我去通过与采摘图像内置的意图,我得到这样的:

When I go through picking the image with the built in intent I get this:

content://media/external/images/media/247 

这些都显示相同的文件,但我没有任何共享选项,当我使用的第一个。

These both display the same file, but I don't have any sharing options when I use the first one.

我的问题是,我怎么能找到开放的内容给出的文件URI?

My question is, how can I find the content Uri given the file Uri?

推荐答案

我在制作文件,所以我有一个文件对象文件

I was making the file, so I had a File object file.

所以,我现在这样做是为了获取的URI文件作为内容://。乌里

So I do this now to get Uri for the file as a "content://" Uri.

Uri capturedImage = Uri.parse(
      android.provider.MediaStore.Images.Media.insertImage(
      getContentResolver(),
      file.getAbsolutePath(), null, null));

感谢回答这个问题,<一个href=\"http://stackoverflow.com/questions/1567732/how-can-i-capture-an-image-in-android-and-have-it-show-up-in-the-gallery\">How我可以捕捉在Android中的图像,并让它在画廊展示?

这篇关于如何将文件转换:// URI到的内容:// URI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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