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:

  1. first register broadcast usb connection. manifest permission:

  2. 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

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -