我想在以下代码中使用USB设备.它成功列出了usb设备并迭代它们.在下面的代码中,对象“device”是我需要打开的usbdevice.除了总是返回null值的OpenDevice()方法之外,一切似乎都很好!
[Activity(Label = "TestApp", MainLauncher = true, Icon = "@drawable/icon")]
[IntentFilter(new[] {UsbManager.ActionUsbDeviceAttached})]
[MetaData(UsbManager.ActionUsbDeviceAttached, Resource = "@xml/device_filter")]
public class MainActivity : Activity
{
int count = 1;
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
UsbManager manager = (UsbManager)GetSystemService(Context.UsbService);
UsbDevice device = null;
foreach (var dev in manager.DeviceList)
{
if (dev.Value.VendorId == 5401)
{
device = dev.Value;
}