Android 无法从照片应用程序获取云图像的路径

标签 android photos

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

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

当我选择 Google Photos 云上的图像时,它将首先下载,然后在 URI 上方提供给我。从那时起,我直接执行查询并在所有列中获取文件“Filename.png”的名称,但不是完整路径。

当我尝试在 Facebook 上分享相同的内容时,它会准确显示我想要分享的内容。

我还引用了 this link to get the path from Photos application ,但问题出在云图像上。

任何人有解决方案或建议都会被采纳。

最佳答案

首先尝试获取位图:

@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.");
        }
    }
}

然后,如果需要,您可以将位图保存到一个临时文件中。

更多详情 here .

关于Android 无法从照片应用程序获取云图像的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32326558/

相关文章:

android - 请参见测试启动状态错误

android - ViewPager InstatiateItem 方法被多次调用

android - 无法在主线程中创建处理程序?

jQuery 砌体 : Creating dynamic container to fill page with content (simulates a tiled background)

android - 启动相机拍照或录制视频

android - AppCompat、Vectors 和 4.1.2 发生奇怪的崩溃

java - 从 json 中检索图像时出现 "The application may be doing too much work on its main thread"错误

iphone - 通过 iPhone 应用程序更改壁纸

android - 光标限制照片

swift - 迭代PHAsset以获取图像标识符Swift