1

I want to add my application to the list of apps Android offers to launch when a digital camera is connected. I've added this to my manifest:

<intent-filter>
  <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />

  <meta-data
     android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
     android:resource="@xml/device_filter" />
</intent-filter>

And specified a filter (class 6 is digital camera, but I've tried empty filter as well):

<resources>
    <usb-device class="6"/>
</resources>

It has no effect, my app is still not in that list. What else do I have to do?

Note that I'm not interested in the broadcast intent, all I need is to make it to the list of choices for handling the device user is presented with.

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
  • Perhaps this can be of some help: http://stackoverflow.com/questions/6163856/usb-device-attached-intent-not-firing – Michael Jan 20 '13 at 09:10

1 Answers1

1

Found the problem. Manifest should be like this:

<intent-filter>
  <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>

<meta-data
   android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
   android:resource="@xml/device_filter" />

I. e. meta-data shouldn't be sub-element of intent-filter like I've put it.

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335