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