title: how to detect if is running the scan for new media files on Android (in background)
body: <p>I have two activity: Main and Processing.
  in the Processing activity do an edit operation on the file names in a folder, and then start a scan to update via broadcast, and I check when the scan finish.</p>
  
  <pre><code>//end batch renaming operation
  //start updating media store library
  sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,Uri.parse("file://"+Environment.getExternalStorageDirectory()))); 
  //show toast "updating"
  op_media_mounted.show();
  //catch when updaitng op ends
  IntentFilter filter = new IntentFilter(Intent.ACTION_MEDIA_SCANNER_FINISHED);
  filter.addDataScheme("file");                   
  BroadcastReceiver mReceiver = (new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
          if (intent.getAction().equals(Intent.ACTION_MEDIA_SCANNER_FINISHED)) {
          Toast.makeText(frm_elabora.this, "Scan complete.", Toast.LENGTH_SHORT).show();
                          }
                      }
                  });
  registerReceiver(mReceiver, filter);   
  </code></pre>
  
  <p>I would like to pass the Activity prevent processing if the scan is running.
  I can check first if the scan is not running, then launch the second processing activity? as this.</p>
  
  <pre><code>Button btnstart = (Button)findViewById(R.id.btn_start);
  btnstart.setOnClickListener(new View.OnClickListener() {
      public void onClick(View view) {
          if ( there_isnt_scan_for_new_media_file )
              startActivity(intent_processing);
          else{
                  wait_until_ACTION_MEDIA_SCANNER_FINISHED
                  startActivity(intent_processing);
          }
  </code></pre>
  
  <p>I need to check this, because if i rename the files while android running a scan, when I edit the files in the processing activity, in the end I find other files in the folder with size 0 bytes, as before the change.
  so I have to wait that the scan finish. i can't find a solution.</p>
  
  <p>UPDATES:
  i've found this</p>
  
  <pre><code>    public static Uri getMediaScannerUri ()
      Since: API Level 1
      Uri for querying the state of the media scanner.
  </code></pre>
  
  <p>i try this</p>
  
  <pre><code>    //send broadcast
      sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, 
              Uri.parse("file://" +
              Environment.getExternalStorageDirectory())));
      //show media scanner state
      Toast.makeText(frm_elabora.this,
          MediaStore.getMediaScannerUri().toString(),
          Toast.LENGTH_SHORT).show();
  </code></pre>
  
  <p>and i get "content://media/none/media_scanner" always... if i ask getMediaScannerUri() after 
   sent ACTION_MEDIA_MOUNTED, i should get something different from "content://media/none/media_scanner" ???</p>