I'm trying to implement a gallery and I have a GridView that displays all the images (thumbnail) in the camera folder. To get the thumbnails, I basically get their IDs using:
final String[] PROJECTION =
new String[] {MediaStore.Images.Media._ID};
Cursor pictureCursor = getActivity().getContentResolver().query(Images.Media.EXTERNAL_CONTENT_URI,
PROJECTION, null, null, MediaStore.Images.Media._ID);
ArrayList<Integer> ids = new ArrayList<Integer>();
int idIndex = pictureCursor.getColumnIndex(MediaStore.Images.Media._ID);
while (pictureCursor.moveToNext()) {
ids.add(pictureCursor.getInt(idIndex));
}
And to read the thumbnails, I'm using
Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(content_resolver, ids.get(position), MediaStore.Images.Thumbnails.MICRO_KIND, null);
on an AsyncTask as specified in http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
But as I'm comparing the load times between my app vs. Android's native gallery app, I'm seeing that the gallery app loads thumbnails MUCH faster than my app, all the while having better image quality than my Thumbnails.MICRO_KIND. Is there a faster way to load thumbnails than to use MediaStore.Images.Thumbnails.getThumbnail()
function? because obviously the gallery app loads thumbnails much faster.
NOTE: this is when the app is initially opened, before cache comes into play. After my cache stores images, then load time is near instant. So, not a cache problem.
EDIT:
I thought I should clarify. It's not that my UI is getting locked or my app is slow, since I'm already using an AsyncTask to read my images off the UI thread. What I'm asking is if the function MediaStore.Images.Thumbnails.getThumbnail()
is the fastest way to load thumbnails already stored on the phone?