I have developed a simple app: in the main activity you can open the gallery and select multiple pictures. Their URIs will be stored in a list, and then in another activity I get the URIs from that list to make some thumbnails of these pictures.
The code I use for those two actions are the following.
On the main activity I get the Uri and convert it into a String:
Uri mImageUri=data.getData();
// Get the cursor
Cursor cursor = getContentResolver().query(mImageUri, filePathColumn, null, null, null);
// Move to first row
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
uriStringList.add(cursor.getString(columnIndex));
cursor.close();
On the second activity I get the Uri in this way:
uriList.add(Uri.parse( "file://" + uriStringList.get(id)));
iwt.setImageBitmap(decodeSampledBitmapFromUri(uriList.get(id), 100, 100));
Everything works smoothly on my Android 5.1 (API 22) smartphone, but when I run the app on my newest Xiaomi smartphone with MIUI 9.2 (Android 7.1.2 API 25), I get a java.IO FileNotFoundException.
Does anybody know the reason of this error?