My app allows a user to save an image to their SD card. But I\'m not sure how to make it appear in the gallery until you unmount and remount the SD card. I have googled for
Here is another way to force scan:
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,"uri to file"));
And then system will fire ACTION_MEDIA_SCANNER_FINISHED broadcast so you can react on it with BroadcastReceiver
In order to be able to receive ACTION_MEDIA_SCANNER_FINISHED broadcast, intent filter should contain data scheme:
IntentFilter intentFilter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_FINISHED);
intentFilter.addDataScheme("file");
context.registerReceiver(mMediaScannerFinishReceiver, intentFilter);
from the doc:
public static final String ACTION_MEDIA_SCANNER_SCAN_FILE
Added in API level 1 Broadcast Action: Request the media scanner to scan a file and add it to the media database. The path to the file is contained in the Intent.mData field.
and
public static final String ACTION_MEDIA_SCANNER_FINISHED
Added in API level 1 Broadcast Action: The media scanner has finished scanning a directory. The path to the scanned directory is contained in the Intent.mData field.