update android image gallery with newly created bitmap

前端 未结 4 1491
温柔的废话
温柔的废话 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:31

    Simply use MediaScannerConnection after you saved your bitmap to sd:

    MediaScannerConnection.scanFile(this,
                    new String[] { Bitmapfile.getAbsolutePath() }, null,
                    new MediaScannerConnection.OnScanCompletedListener() {
                        public void onScanCompleted(String path, Uri uri) {
                            //now visible in gallery
                        }
                    }
                );
    

提交回复
热议问题