Android camera Intent not saving in gallery [dupli

2019-03-03 17:16发布

问题:

This question already has an answer here:

  • Android Newly Taken Photo from custom camera does not appear in gallery (media store) 3 answers

I am creating a simple application which takes pictures using the camera intent. It works and the pictures are being saved in : storage/emulated/sd/pictures/my_folder . The problem is that I can't see those pictures from the Android Gallery app.

I saw different posts about but I couldn't find an answer. How can I watch the pictures?

Thanks

回答1:

You just need to send an broadcast "ACTION_MEDIA_SCANNER_SCAN_FILE" so that the mediascanner can scan for the image you saved.

 Intent mediaScanIntent = new Intent( Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
 mediaScanIntent.setData(uri);
 sendBroadcast(mediaScanIntent);

just set the uri of the the newly created image. :)

Click to view Source :)