title: Can't receive broadcast Intent of UsbManager.ACTION_USB_DEVICE_ATTACHED/UsbManager.ACTION_USB_DEVICE_DETACHED
body: <p>I am coding an USB host App recently, but it's stucked because I can't detect the device attached/detached event, I followed the coding note of  <a href="http://developer.android.com/guide/topics/connectivity/usb/host.html">http://developer.android.com/guide/topics/connectivity/usb/host.html</a> and refer to other's coding in the network, After checking several times, I still can't find the problem. After my debugging, it seems that the UsbManager.ACTION_USB_DEVICE_ATTACHED/UsbManager.ACTION_USB_DEVICE_DETACHED intent is not happened, Because I try to use Context.sendBroadcast() to send a customized Intent, and my BroadcastReceiver can receive the intent. But when I attach/detach the USB device, the BroadcastReceiver don't run. The cellphone I use is HTC One-X, I am sure the OTG function is correct as the mouse function working perfectly. 
  Here is my code piece.</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.launcher);
      mUsbManager = (UsbManager)getSystemService(Context.USB_SERVICE);
      if(mUsbManager == null) {
          Log.d(TAG, "mUsbManager is null");
      }
  
      // listen for new devices
      IntentFilter filter = new IntentFilter();
      filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
      filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
    // filter.addAction("MyTest");
      registerReceiver(mUsbReceiver, filter);
  
  }
  </code></pre>
  
  <p>The BroadcastReceiver</p>
  
  <pre><code>BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
      public void onReceive(Context context, Intent intent) {
          Log.d(TAG, "mUsbReceiver.onReceive start");
          String action = intent.getAction();
          UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
          if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) {
              setDevice(device);
          } else if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
              if (mDevice != null &amp;&amp; mDevice.equals(device)) {
                  setDevice(null);
              }
          }
      }
  };
  </code></pre>
  
  <p>Manifest.xml</p>
  
  <p></p>
  
  <pre><code>&lt;uses-feature android:name="android.hardware.usb.host" /&gt;
  &lt;uses-permission android:name="android.permission.USB_PERMISSION" /&gt;
  &lt;uses-sdk android:minSdkVersion="12" /&gt;
  
  &lt;application&gt;
      &lt;activity android:name=".USBActivity"
          android:label="USBActivity"
          android:screenOrientation="portrait"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
  
      &lt;!--     &lt;receiver android:name=".mUsbReceiver"&gt; --&gt;
  
          &lt;intent-filter&gt;
              &lt;action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /&gt;
              &lt;action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" /&gt;
          &lt;/intent-filter&gt;
  
          &lt;meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
              android:resource="@xml/device_filter" /&gt;
          &lt;meta-data android:name="android.hardware.usb.action.USB_DEVICE_DETACHED"
              android:resource="@xml/device_filter" /&gt;
     &lt;!--     &lt;/receiver&gt; --&gt;
  
          &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>device_filter in res/xml, all 3 settings are tried and no-use:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;resources&gt;
    &lt;!-- iCooby mouse --&gt;
    &lt;!--     &lt;usb-device vendor-id="15d9" , /&gt; --&gt;
    &lt;!--     &lt;usb-device vendor-id="5593" product-id="2637"/&gt; --&gt;
      &lt;usb-device /&gt;
   &lt;/resources&gt;
  </code></pre>
  
  <p>If someone know what's happened? or tell me how to detect if the broadcast intent is active or not, thanks very much.</p>