Android picture saved to SD card not showing in Gallery

后端 未结 3 1480
走了就别回头了
走了就别回头了 2020-12-21 12:39

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

相关标签:
3条回答
  • 2020-12-21 13:19

    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);
    
    0 讨论(0)
  • 2020-12-21 13:20

    Try this answer. Working for me

    context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(finalFile)));
    
    0 讨论(0)
  • 2020-12-21 13:20

    Maybe someone is "overseeing" it...

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

    0 讨论(0)
提交回复
热议问题