开发者

Android picture saved to SD card not showing in Gallery

开发者 https://www.devze.com 2023-03-19 16:33 出处:网络
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 th开发者_如何学Cere something I must do to make it happe

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 th开发者_如何学Cere something I must do to make it happen?


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);


Try this answer. Working for me

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


Maybe someone is "overseeing" it...

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号