android - Saved image takes minutes to appear in Gallery -
i'm saving bitmap in sd card , called intent.action_media_mounted
right after.
it displays in gallery takes 5 minutes image appear. there way make instantaneous?
file newfile = new file(newfilename); if (newfile.exists()) { newfile.delete(); } try { fileoutputstream out = new fileoutputstream(newfile); bitmap.compress(bitmap.compressformat.jpeg, 100, out); out.flush(); out.close(); context.sendbroadcast(new intent(intent.action_media_mounted, uri.parse("file://" + environment.getexternalstoragedirectory()))); toast.maketext(context, "photo appear in gallery in few minutes.", toast.length_short).show(); } catch (exception e) { e.printstacktrace(); }
you need pass file mediascannerconnection : http://developer.android.com/reference/android/media/mediascannerconnection.html .
way system can instantly knows there new file needs added gallery.
right now, have wait until system scans filesystem , see file, of course not instantaneous.
, way, when have implemented this, should able remove intent.action_media_mounted call, not here broadcast file additions (mediascannerconnection is).
Comments
Post a Comment