I have tried writing primitive activity for scanning USB port and displaying basic info for attached device. I am specifically interested in reading device class, which I believe UsbDevice.getDeviceClass () method is intended for. Here's what it looks like:
HashMap<String, UsbDevice> deviceList = findUsbDevices();
Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
if (deviceIterator.hasNext())
{
UsbDevice device = deviceIterator.next();
String name = device.toString();
String cls = Integer.toString(device.getDeviceClass());
displayDeviceInfo(name, cls);
}
However, it doesn't work as expected, giving 0 for any device I connect. Many other fields of UsbDevice object, like subclass or protocol, are also 0. How can I get device class then?