问题
How can I get the id (or some unique properties) of the USB devices connected to my Android device?
回答1:
For anyone new to UsbDevice, it may be worth noting the use of UsbManager
UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> usbDevices = usbManager.getDeviceList();
Read more at http://developer.android.com/reference/android/hardware/usb/UsbManager.html
回答2:
You can get the unique ID of an android connected USB device using UsbDevice.getDeviceId() method.
Please check the below links for more details. http://developer.android.com/reference/android/hardware/usb/UsbDevice.html#getDeviceId()
More than Id, Please check other methods of class 'UsbDevice'. http://developer.android.com/reference/android/hardware/usb/UsbDevice.html
来源:https://stackoverflow.com/questions/7488521/how-can-i-get-the-id-or-some-unique-properties-of-the-usb-devices-connected-to