How to convert a file:// uri into content:// uri?

匿名 (未验证) 提交于 2019-12-03 03:06:01

问题:

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.

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

回答1:

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

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));

Credit to answer on this question How can I capture an image in Android and have it show up in the gallery?



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!