I tried to use the following codes to
Problem - When I try to save the image, it shows a null
There is a little add on in the above code. The above code is saving the pic in the storage. But the Image is not showing in the gallery. To show the image in gallery just need to setup a MediaScannerConnection
for the bitmap we are saving
Sample Function
public void scanPhoto(final String imageFileName) {
MediaScannerConnection msConn = new MediaScannerConnection(PaintPic.this,
new MediaScannerConnectionClient() {
public void onMediaScannerConnected() {
msConn.scanFile(imageFileName, null);
Log.i("msClient obj in Photo Utility",
"connection established");
}
public void onScanCompleted(String path, Uri uri) {
msConn.disconnect();
Log.i("msClient obj in Photo Utility", "scan completed");
}
});
msConn.connect();
}
and call this function just after this line
save.compress(Bitmap.CompressFormat.PNG, 100, ostream);
Now the saved bitmap is also visible in the Gallery