Android无法从相册应用程序中获取云图像的路径

4
我曾经尝试获取绝对路径并且成功了,但是当我尝试使用云图像在应用文件中获取该图像时,它找不到并返回了空值。我正在实现从另一个应用程序接收文件的功能,例如从照片、图库或文件应用程序选择图像,并使用我的应用程序共享图像。

这里我得到了Uri content://com.google.android.apps.photos.contentprovider/0/1/mediaKey%3A%2FAF1QipOFLMMm8uXbeDMQk-P4S0Hx1dlmRDMr4SFABfVi/ACTUAL/61235243

当我选择储存在Google Photos云上的图像时,它会首先下载然后给我上述URI。从那一点开始,我直接执行查询并在所有列中获取文件名“Filename.png”,但未获取到完整路径。

当我尝试使用Facebook分享时,它将显示我想要分享的内容。

我还从此链接中获取了信息,在照片应用程序中获取路径,但问题在于云图像。

如果有任何解决方法或建议,将不胜感激。

1个回答

1
尝试先获取 Bitmap:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
        Uri selectedImage = data.getData();

        InputStream inputStreamBitmap = null;
        Bitmap imageBitmap = null;
        try {
            inputStreamBitmap = getContentResolver().openInputStream(inputStreamBitmap);
            imageBitmap = BitmapFactory.decodeStream(inputBitmap);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
            try {
                if (inputStreamBitmap != null) {
                    inputStreamBitmap.close();
                }
            } catch (IOException ignored) {
            }
        }
        if (imageBitmap != null) {
            processImageBitmap(imageBitmap);
        } else {
            Log.e("ImageIntent", "Error: couldn't open the specified image.");
        }
    }
}

如果您愿意,可以将Bitmap保存到临时文件中。

更多详细信息在这里


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接