My app has ability to select photo from library. Exactly I want file path from this selection.
This is the code to create intent for selecting photo:
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK,
MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, INTENT_REQUEST_CODE_SELECT_PHOTO);
This is the code that gets file path from URI:
Cursor cursor = null;
String path = null;
try {
String[] projection = { MediaStore.Images.Media.DATA };
cursor = context.getContentResolver().query(contentUri, projection, null, null, null);
int columnIndex = cursor.getColumnIndexOrThrow(projection[0]);
cursor.moveToFirst();
path = cursor.getString(columnIndex);
} finally {
if (cursor != null) {
cursor.close();
}
}
return path;
Before yesterday's update of Google Photos app everything worked perfectly fine.
Now path
is null after parsing URI.
URI is similar to this: content://com.google.android.apps.photos.contentprovider/0/1/content%3A%2F%2Fmedia%2Fexternal%2Fimages%2Fmedia%2F75209/ACTUAL
I also tried to create intent with Intent.ACTION_GET_CONTENT action - no luck.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…