Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Eclipse Querying thumbnails of images stored outside of gallery

Are you able to use MediaStore's queryMiniThumbnails method on images that you store in a custom location (for example /sdcard/testimages)?

When you add a new image to that custom location, does it automatically generate a thumbnail, or is that something I would have to do as I am adding the photos?

like image 833
Nick Avatar asked Nov 04 '22 09:11

Nick


1 Answers

After you store the image in your custom location, you can call MediaScannerConnection.scanFile(String path, String mimeType) to have it added right away. I believe this should add it to the Gallery and thus generate a thumbnail for it. You could then use the queryMiniThumbnails method.

There's also a convenience version of scanFile with a callback that sets up the MediaScannerConnection for you and implements a callback so you can operate on the results when it is done:
scanFile(Context context, String[] paths, String[] mimeTypes, MediaScannerConnection.OnScanCompletedListener callback)

Please give this a try. I haven't tested this exact workflow so not sure if it will work out.

like image 121
Marc Bernstein Avatar answered Nov 09 '22 05:11

Marc Bernstein