【发布时间】:2017-04-19 15:33:52
【问题描述】:
我有一个允许使用外部应用程序选择照片的应用程序。然后我从 uri 中获取照片的路径并将其用于内部操作。
当用户使用 Google Photo 选择照片时,如果该照片是本地存储的,则下一个代码可以完美运行。但如果图片在云端,cursor.getString(index) 的结果为空。
我已经搜索了一些信息,但不确定解决方案
final String[] projection = { "_data" };
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
final int index = cursor.getColumnIndexOrThrow("_data");
return cursor.getString(index);
}
谢谢!
【问题讨论】:
-
看起来像这个的副本? stackoverflow.com/questions/30527045/…
-
@user2765258 我看到了那个帖子。但不是一个好的解决方案。甚至用户说接受它是因为解决了问题但不是他实施的完整解决方案。还是谢谢你