Android picture saved to SD card not showing in Gallery

雨燕双飞 提交于 2019-11-28 09:52:42

问题


Currently I have a program that takes pictures and saves them as a jpg on the top level of the sdcard, but its not appearing in the Gallery. Is there something I must do to make it happen?


回答1:


You need to call the MediaScanner so that it knows your file exists:

File file; // = your file
String mimetype; // = your file's mimetype. MimeTypeMap may be useful.
MediaScanner.scanFile(getApplicationContext(), new String[]{file.getPath()}, new String[]{mimetype}, null);



回答2:


Try this answer. Working for me

context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(finalFile)));



回答3:


Maybe someone is "overseeing" it...

Take a look at:
https://stackoverflow.com/a/5110571/371749



来源:https://stackoverflow.com/questions/6673809/android-picture-saved-to-sd-card-not-showing-in-gallery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!