我无法从所选图像Uri中读取数据部分,这发生在某些特定设备Lg nexus 5 api 6.0.1上
所选图片的Uri
content://com.google.android.apps.photos.contentprovider/-1/1/content://media/external/images/media/200/ORIGINAL/NONE/2077196451
用于从uri获取数据的代码
public static String getDataColumn(Context context, Uri uri, String selection,
String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = {
column
};
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
null);
if (cursor != null && cursor.moveToFirst()) {
final int index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(index);
}
}catch (Exception e){
e.printStackTrace();
}
finally {
if (cursor != null)
cursor.close();
}
return null;
}
权限处理没有问题,给出了必需的权限。