Im adding images to a folder on the SDCARD. Since the images and my folder is not immediately visible in the Gallery im trying to get the MediaScannerConnection to update an
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 mediaScannerConnectionClient =
new MediaScannerConnectionClient() {
@Override
public void onMediaScannerConnected() {
mediaScannerConnection.scanFile("pathToImage/someImage.jpg", null);
}
@Override
public void onScanCompleted(String path, Uri uri) {
if(path.equals("pathToImage/someImage.jpg"))
mediaScannerConnection.disconnect();
}
};
new MediaScannerConnection(context, mediaScannerConnectionClient).connect();