Android : how to detect already connected usb device? -
i'm trying detect usb devices connected android. understand there actions detect when usb either attached or detached. don't how check devices after connecting usb device android. also, i've found each usb device has it's device class code, how figure out kind of device connected? instance, need detect both usb mouse , keyboard; how differentiate them?
try this:
first register broadcast usb connection. manifest permission:
get list of usb device details using this
public void getdetail(){ usbmanager manager = (usbmanager)getsystemservice(context.usb_service); hashmap<string, usbdevice> devicelist = manager.getdevicelist(); iterator<usbdevice> deviceiterator = devicelist.values().iterator(); while(deviceiterator.hasnext()){ usbdevice device = deviceiterator.next(); manager.requestpermission(device, mpermissionintent); string model = device.getdevicename(); string deviceid = device.getdeviceid() string vendor = device.getvendorid(); string product= device.getproductid() ; string class = device.getdeviceclass() ; string subclass = device.getdevicesubclass(); }
Comments
Post a Comment