Android SDCard mounting delay
<p>I have an activity in my application which is basically a gallery which displays the pictures located on my sdcard. I am using this function to remount the sdcard to scan for new images when the activity starts:</p>

<pre><code>    sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));    
</code></pre>

<p>The thing is when i do this the gallery does not show the updated images as android takes time to scan. So I put a sleep after that to wait for the scan to finish like this:</p>

<pre><code>    sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));    

    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
</code></pre>

<p>This works but makes the application pause for 2 seconds. Is there a better way to handle this by putting a loading dialog? I'm not sure how to identify when the sdcard scan has been completed so that I can resume the activity.</p>
