How can I get the id (or some unique properties) of the USB devices connected to my Android device, programmatically?

自作多情 提交于 2019-12-11 06:46:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!