Code example for UsbManager

Methods: getAccessoryListhasPermission

            //       Note however that the IDE still thinks that Gingerbread is required 
            //       thus the use of the `@TargetAPi(12)` above. 
            UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);
            UsbAccessory[] accessoryList = manager.getAccessoryList();
            // Note: The permissions check here is because sometimes we end up 
            //       with spurious accessories (e.g. ^B in the device description etc) 
            //       and presumably it also stops problems if an accessory is connected 
            //       when we're open. 
            result = ((accessoryList != null) && (manager.hasPermission(accessoryList[0])));
        } catch (ClassNotFoundException e) {
                    "No USB accessory support, 'android.hardware.usb.UsbManager' not found."); 
        return result;
Connect your IDE to all the code out there  Get Codota for Java