【问题标题】:Android Unable to get path for Cloud image from Photos ApplicationAndroid 无法从照片应用程序获取云图像的路径
【发布时间】:2015-09-01 08:05:53
【问题描述】:

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

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

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

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

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

任何有解决方案或建议的人都将受到欢迎。

【问题讨论】:

    标签: android photos


    【解决方案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 保存到临时文件中。

    更多详情here.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-30
      • 2013-01-20
      • 1970-01-01
      • 2017-08-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多