title: Android: BroadcastReceiver when insert/remove the device USB plug into/from a USB port
body: <p>My application don't catch "ACTION_USB_DEVICE_ATTACHED" but "ACTION_USB_DEVICE_DETACHED" work fine.
  Application start correctly if I connect usb device but I disconnect during execution <code>BroadcastReceiver</code> right catch "ACTION_USB_DEVICE_DETACHED". If I attach again <code>BroadcastReceiver</code> don't catch anything.</p>
  
  <pre><code>    IntentFilter filter = new IntentFilter();
  filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
  filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
  rocrailService.registerReceiver(mUsbReceiver, filter);
  
  
    // BroadcastReceiver when insert/remove the device USB plug into/from a USB port  
    BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
    public void onReceive(Context context, Intent intent) {
      String action = intent.getAction();
      System.out.println("BroadcastReceiver Event");
      if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) {
          mSerial.usbAttached(intent);
          mSerial.begin(mBaudrate);
          loadDefaultSettingValues();
          Run=true;
          start();
          System.out.println("BroadcastReceiver USB Connected");
  
      } else if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
          mSerial.usbDetached(intent);
          mSerial.end();
          Run=false;
          System.out.println("BroadcastReceiver USB Disconnected");
      }
    }
  </code></pre>
  
  <p>And manifest:</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="net.DCCWLocoDisplay"
  android:versionCode="0"
  android:versionName="0" &gt;
  
  &lt;uses-sdk android:targetSdkVersion="12"/&gt;
  &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.WRITE_SETTINGS"/&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;   
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/&gt;
  
  &lt;application
      android:icon="@drawable/dccw"
      android:label="@string/app_name" &gt;
      &lt;activity android:icon="@drawable/cab_64" android:name="net.DCCWLocoDisplay.activities.ActRCCab" android:theme="@style/FullHeightMainDialog" android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /&gt;
          &lt;/intent-filter&gt;
              &lt;meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" 
                 android:resource="@xml/device_filter" /&gt;      
      &lt;/activity&gt;
      &lt;activity android:name="net.DCCWLocoDisplay.activities.ActPreferences" android:theme="@style/FullHeightDialog" /&gt;
      &lt;activity android:name="net.DCCWLocoDisplay.activities.ActAccessory" android:theme="@style/FullHeightDialog" /&gt;
      &lt;activity android:name="net.DCCWLocoDisplay.activities.ActAbout" android:theme="@style/FullHeightDialog" /&gt;
      &lt;activity android:name="net.DCCWLocoDisplay.activities.ActProgramming" android:theme="@style/FullHeightDialog" /&gt;
      &lt;activity android:name="net.DCCWLocoDisplay.activities.ActSteps" android:theme="@style/FullHeightDialog" /&gt;
      &lt;service android:name="net.DCCWLocoDisplay.DCCWLocoDisplay"/&gt;
      &lt;/application&gt;
  
   &lt;/manifest&gt;
  </code></pre>
  
  <p>Device filter (I check vendor and product id):</p>
  
  <pre><code>&lt;resources&gt;
  &lt;!-- 0x0403 / 0x6001: FTDI FT232R UART --&gt;
  &lt;usb-device vendor-id="1027" product-id="24577" /&gt; &lt;!-- FT232RL --&gt;
  &lt;/resources&gt;
  </code></pre>