我正在尝试从图库中读取图片。我正在使用带有marshmallow android版本的Motorola G2设备。
方法:
public String getPath(Uri uri) {
String[] projection = {MediaStore.Images.Media.DATA};
// Cursor cursor = this.getActivity().getContentResolver().query(uri, projection, null, null, null);
Cursor cursor = this.getActivity().managedQuery(uri, projection, null, null, null);
int column_index = cursor.getColumnIndex(projection[0]);
System.out.println("In Iconiq:: In postImage:: Index:: " + column_index);
cursor.moveToFirst();
return cursor.getString(column_index);
}