如何将文件:// uri转换为content:// uri?

wes*_*ton 7 android uri

我发现在我的设备上,如果我有一个uri,默认的媒体显示工具并没有向我展示:

file://mnt/sdcard/DCIM/Image.jpg
Run Code Online (Sandbox Code Playgroud)

当我使用内置意图选择图像时,我得到了这个:

content://media/external/images/media/247 
Run Code Online (Sandbox Code Playgroud)

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

我的问题是,如何找到文件Uri的内容Uri?

wes*_*ton 11

我正在制作文件,所以我有一个File对象file.

所以我现在这样做是为了让文件的Uri作为"content://"Uri.

Uri capturedImage = Uri.parse(
      android.provider.MediaStore.Images.Media.insertImage(
      getContentResolver(),
      file.getAbsolutePath(), null, null));
Run Code Online (Sandbox Code Playgroud)

有信心回答这个问题如何在Android中捕获图像并将其显示在图库中?