sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"
+ Environment.getExternalStorageDirectory())));
Do not do the sendBroadcast if you only want one image to appear in the gallery. That'd be a huge waste of resources. You'll need to make a MediaScannerConnectionClient and then call connect() on the MediaScannerConnection you make from it to scan the file. Here's an example:
private MediaScannerConnectionClient _mediaScanConnectionClient =
new MediaScannerConnectionClient() {
public void onMediaScannerConnected() {
MEDIA_SCANNER_CONNECTION.scanFile("pathToImage/someImage.jpg", null);
}
public void onScanCompleted(String path, Uri uri) {
if(path.equals("pathToImage/someImage.jpg"))
MEDIA_SCANNER_CONNECTION.disconnect();
}
};
new MediaScannerConnection(context, _mediaScanConnectionClient).connect();