Android list usb devices

2.9k views Asked by At

Hy out there I try to list all usb devices which are connected to my android tablet. I use https://play.google.com/store/apps/details?id=hu.sztupy.android.usbhostcontroller&hl=en to check if the device decteds the usbkeyboard and yes it does on both tablets and the tastatur is working on both tablets. the code looks like

  UsbManager mUsbManager;
     mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
        mUsbManager.getDeviceList();  
        HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList(); 
        Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
        this.outputtext.append(deviceList.size()+"Geräte gefunden");
        this.outputtext.append(mUsbManager.toString());
        UsbDevice device=null;       
 while(deviceIterator.hasNext()){
            device = deviceIterator.next();  
            this.outputtext.append( device.getDeviceName()+" vendorid: "+device.getVendorId()+"  productid"+device.getProductId());
}

The strange thing is, that it works on my archos titanium hd but it doesnt work on my fujitsu m532. what am i doing wrong?

best regards

1

There are 1 answers

0
Tian Pretorius On

Just check the API level of your fujitsu m532, because getSystemService() requires a minimum API level of 23 (Android version 6.0).