update android image gallery with newly created bitmap

前端 未结 4 1474
温柔的废话
温柔的废话 2020-12-17 06:20

I\'m trying to save an image file to external storage. I can save the picture to the sdcard but it doesn\'t show up in Androids gallery application. I\'ve tried this approac

4条回答
  •  时光取名叫无心
    2020-12-17 06:25

    I know i am a little late to answer this but i guess for anyone else reading this the answer given by surendra is right and that using the MediaScannerConnection is a way to update the gallery. As for the way nevva was suggesting the changes to his code are :

        Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
        Uri contentUri = Uri.fromFile(f);
        mediaScanIntent.setData(contentUri);
        getApplicationContext().sendBroadcast(mediaScanIntent);
    

提交回复
热议问题