I am trying to save an image, and alert the Gallery about the new image. The image is not immediately shown in the gallery, but it can take even a few hour to refresh. I use the following code:
String title = "title";
String r = MediaStore.Images.Media.insertImage(getContentResolver(), State.pictureWithDekor, title, title);
Uri uri = Uri.parse(r);
MediaScannerConnection.scanFile(this,
new String[] { uri.getPath() }, null,
new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Log.i("TAG", "Finished scanning " + path);
}
});
the value of r
after the insertImage
is content://media/external/images/media/2082
, the uri
in the onScanCompleted is null
.
What am I doing wrong?