title: How to intercept Intent ACTION_MEDIA_MOUNTED broadcast in Android?
body: <p>I have an Android app that handles plug-ins of my specific storage device. I want to be able to show the contents of the storage device in a specific way with my Display activity when the device is mounted on the system. The problem I'm having is that on some phones the system also handles the <code>ACTION_MEDIA_MOUNTED</code> broadcast and then automatically brings up the Android file explorer (which takes the screen away from my app). This is what I am trying to prevent if at all possible. I am registering a broadcast receiver to listen for the <code>ACTION_MEDIA_MOUNTED</code> broadcast and then starting my Display activity as soon as I receive this broadcast like so:</p>
  
  <pre><code>BroadcastReceiver mediaMountedReceiver = new BroadcastReceiver()
  {
      @Override
      public void onReceive(Context context, Intent intent)
      {
          Log.d("debug", "HEAR YE! HEAR YE! THE MEDIA HAS BEEN MOUNTED!");
          if (isOrderedBroadcast()) {
              abortBroadcast();
          }
          Intent i = new Intent(getApplicationContext(), Display.class);
          startActivity(i);
      }
  };
  
  ...
  
  IntentFilter filter = new IntentFilter();
  filter.addAction(Intent.ACTION_MEDIA_MOUNTED);
  filter.addDataScheme("file");
  filter.setPriority(999);
  registerReceiver(mediaMountedReceiver, filter);
  </code></pre>
  
  <p>I receive the broadcast alright and I try to cancel it by calling <code>abortBroadcast()</code> but apparently <code>ACTION_MEDIA_MOUNTED</code> is not an ordered broadcast. Is there any way to stop propagation of this broadcast or to direct all storage mount/unmount broadcasts to my app?</p>
  
  <p>If this is not possible does anyone have tips or workarounds on how to deal with this?</p>