I have Moto X Pure 2015 with Android 6.0 on the board. Before updating to Android 6 my code of obtaining thumbnail of last captured image on external storage are worked fine. More over, that code works on all devices I've tested (several tens). I can't localize what's changed in Android 6 to broke my code in such way. All dynamic permission is granted and 'write to external storage' too. So, that's what I do to get thumbnail. First I query Cursor and get _id of first founded file (Media - it's just a container of some data, including _id of founded image):
Uri baseUri = Images.Media.EXTERNAL_CONTENT_URI;
Uri query = baseUri.buildUpon().appendQueryParameter("limit", "1").build();
String[] projection = new String[] { ImageColumns._ID, ImageColumns.ORIENTATION, ImageColumns.DATE_TAKEN };
String selection = ImageColumns.DATA + " like '%" + dirName + "%' AND " + ImageColumns.MIME_TYPE
+ "='image/jpeg'";
String order = ImageColumns.DATE_TAKEN + " DESC," + ImageColumns._ID + " DESC";
Cursor cursor = null;
try
{
cursor = resolver.query(query, projection, selection, null, order);
if (cursor != null && cursor.moveToFirst())
{
final long id = cursor.getLong(0);
externalMedia = new Media(id, cursor.getInt(1), cursor.getLong(2), ContentUris.withAppendedId(
baseUri, id));
}
} finally
{
if (cursor != null)
{
cursor.close();
}
}
Now I try to get Bitmap for image with that _id (externalMedia container contains that id):
Bitmap bitmap = Images.Thumbnails.getThumbnail(resolver, externalMedia.id, Images.Thumbnails.MICRO_KIND, null);
And bitmap is null ((((
I didn't found any changes in Android 6 from Android 5 in ContentResolver and Images.Thumbnails parts. So now I'm stuck with that issue.