getDeviceList()总是空 [英] getDeviceList() always empty
问题描述
我试图用一个Arduino板连同我ODYS新X8平板,但现在看来,该UsbManager无法识别该设备没有问题。连接了的Arduino到片剂经由OTG适配器,以使药片将工作在主机模式下,所述的Arduino被成功接收电力从装置。 我获取可用的USB-设备列表上的平板电脑如下:
I'm trying to use an Arduino Board along with my Odys Neo x8 tablet but it seems, that the UsbManager doesn't recognize the device alright. I connected the arduino to the tablet via an OTG-adapter so that the tablet will work in host mode, the Arduino is successfully receiving power from the device. I'm fetching the list of available USB-devices on the tablet as follows:
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里面:
And inside the class UsbController:
mUsbManager = (UsbManager) mApplicationContext
.getSystemService(Context.USB_SERVICE);
不过遗憾的是,该列表是空的,即使我使用的VID和PID(两个零)开始过滤。 如何解决这个问题有什么建议?
But unfortunately, the list remains empty, even if i start filtering using the VID and the PID (the two zeros). Any suggestions on how to fix this?
推荐答案
我使用了下列code的工作很细的键盘,鼠标和大容量存储设备与PANDABOARD连接,
I have used the following code which works very fine with keyboard, mouse and Mass Storage device to connect with Pandaboard,
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的了。
This should work with Arduino too.
这篇关于getDeviceList()总是空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!