I am doing research delving into the Android ADK. So far, my program gets the list of attac开发者_StackOverflow中文版hed devices from the USBManager class and displays basic information about them. The USB Host mode works well and recognizes multiple connected devices even when they are two or three USB hubs away. However, the list never contains USB mice or USB keyboards, even though these devices are recognized by the system and used for input (typing into a text area, etc.). It seems that the system grabs these and doesn't present them to the ADK framework.
Is this functionality intentional? Is there any way to get access to these HID devices? As far as I know, the only to ways to get access to USB devices in Android host mode are the USB Manager and intent filters. Another poster came to the conclusion that neither allows access to HID devices.
Thanks in advance for any information or comments about this topic; I'd really like to get access to mice/keyboards so I can practice USB communication with simple devices.
What version are you testing on? 2.3.4 or 3.1? Did you try using com.android.future.usb or android.hardware.usb?
If you can already use the HID device for input, it' working as a input device(keyboard or mouse) and you don't need to access it as a USB device. You can simply catch the input from the device via listeners such as OnKeyListener.
If you want to check the input devices, see Can't see mouse and keyboard device with usbManager android.
精彩评论