title: Android 3.1 USB-Host - BroadcastReceiver does not receive USB_DEVICE_ATTACHED
body: <p>I worked through <a href="http://developer.android.com/guide/topics/usb/host.html" rel="noreferrer">the description and samples for USB host at developer.android.com</a> to detect attached and detached USB-devices. </p>
  
  <p>If I use an intent-filter in the manifest file to start my application when a device is attached, it works perfectly fine: Plug in, device is detected, android asks for permission to start the application, device information is displayed in a table. </p>
  
  <p>The application I'm developing shouldn't be started/finished only if a device is attached/detached (e.g. data management purposes). Also I do not want the open-dialog to pop up if the app is already running. So I decided not to start the activity directly if a device is attached, but to register a BroadcastReceiver, which is (later) supposed to notify the activity if a device is at-/detached. This receiver recognizes the detach-action just fine, but not the attach-action.</p>
  
  <p>Am I missing a permission or data attribute or something like that? The tutorial and samples don't say anything about additional necessary attributes.</p>
  
  <p>Here is the manifest file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest 
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="de.visira.smartfdr"
    android:versionCode="1"
    android:versionName="1.0"&gt;
  
  &lt;uses-sdk android:minSdkVersion="12" /&gt;
  &lt;uses-feature android:name="android.hardware.usb.host" /&gt;
  
  &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
  
  
      &lt;receiver android:name=".usb.Detector"&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;/receiver&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>And the receiver:</p>
  
  <pre><code>public class FDRDetector extends BroadcastReceiver{
  
  @Override
  public void onReceive(Context context, Intent intent) {
      String action = intent.getAction();
  
      Toast.makeText(context, "Action: " + action, 3).show();
              // pops up only if action == DETACHED
  }
  </code></pre>
  
  <p>I don't understand why the same intent-filter works, if I use them on an activity, but not if they are applied to a receiver? Even if I set up the receiver and filter in code, attaches are not recognized.</p>
  
  <p>My work environment:
  IDE: Eclipse 3.7 with Android Plugin </p>
  
  <p>Device: Acer Iconia Tab A500</p>
  
  <p>Android: 3.1</p>
  
  <p>Thanks in advance</p>