[mono-android] GetAccessoryList?

Jonathan Pryor jonp at xamarin.com
Thu Jun 7 20:44:22 UTC 2012


On Jun 7, 2012, at 2:19 PM, theshadow124 wrote:
> I added:
>  <uses-permission android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />

Did you add:

	<uses-feature android:name="android.hardware.usb.accessory" />

If you want to be notified of an attached USB accessory, you need to have an Activity which handles the android.hardware.usb.action.USB_ACCESSORY_ATTACHED Intent action and provide appropriate metadata; you can do this using C# custom attributes:

	[Activity]
	[IntentFilter (new[]{"android.hardware.usb.action.USB_ACCESSORY_ATTACHED"})]
	[MetaData ("android.hardware.usb.action.USB_ACCESSORY_ATTACHED", Resource="@xml/accessory_filter")]
	public class MyActivity : Activity {
		// ...
	}

You would also need to create a Resources\xml\accessory_filter.xml file, as the Android documentation stipulates:

	http://developer.android.com/guide/topics/usb/accessory.html#manifest

 - Jon



More information about the Monodroid mailing list