关于android:getDeviceList()始终为空

getDeviceList() always empty

我正在尝试将Arduino开发板与我的Odys Neo x8平板电脑一起使用,但似乎UsbManager无法识别该设备。我通过OTG适配器将arduino连接到平板电脑,以便平板电脑可以在主机模式下工作,Arduino已成功从设备获得电源。
我在平板电脑上获取可用USB设备的列表,如下所示:

1
2
3
4
sUsbController = new UsbController(this, mConnectionHandler, 0, 0);
        HashMap<String, UsbDevice> devlist = sUsbController.mUsbManager.getDeviceList();
        TextView t = ((TextView)findViewById(R.id.textView));
        t.setText("Found" + Integer.toString(devlist.size()) +" devices");

在类UsbController中:

1
2
mUsbManager = (UsbManager) mApplicationContext
            .getSystemService(Context.USB_SERVICE);

但是不幸的是,即使我开始使用VID和PID(两个零)进行过滤,列表也仍然为空。
有关如何解决此问题的任何建议?


我使用了以下代码,该代码在键盘,鼠标和大容量存储设备上可以很好地与Pandaboard连接,

1
2
3
4
5
6
7
8
9
  UsbManager usbManager = (UsbManager) getSystemService(USB_SERVICE);
  HashMap<String, UsbDevice> devicelist = usbManager.getDeviceList();
  Iterator<UsbDevice> deviceIterator = devicelist.values().iterator();

  while(deviceIterator.hasNext()) {
    UsbDevice usbDevice = deviceIterator.next();
    Log.i(Log_Tag,"Model     :" +usbDevice.getDeviceName());
    Log.i(Log_Tag,"Id        :" +usbDevice.getDeviceId());
  }

这也应该与Arduino一起使用。


Arduino板需要一个驱动程序,需要先安装驱动程序,然后才能对其进行访问。

我不确定您是否具有Android驱动程序的端口。

编辑:

也请在另一个线程中查看此答案。