I have a Lollipop based android box. The box has a USB port similarly to micro USB port in Android phones. I want to check if any host is connected to the USB port with the andr
UsbManager m = (UsbManager)getApplicationContext().getSystemService(USB_SERVICE);
HashMap usbDevices = m.getDeviceList();
Collection ite = usbDevices.values();
UsbDevice[] usbs = ite.toArray(new UsbDevice[]{});
for (UsbDevice usb : usbs) {
Log.d("Connected usb devices","Connected usb devices are "+ usb.getDeviceName());
}