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
you can use the Android USBManager like in this thread Android : how to detect already connected usb device? or you can install libusb on android: https://github.com/libusb/libusb/tree/master/android
(https://developer.android.com/guide/topics/connectivity/usb/host.html, https://electronics.stackexchange.com/questions/49140/what-exactly-are-the-difference-between-a-usb-host-and-device)
UsbManager m = (UsbManager)getApplicationContext().getSystemService(USB_SERVICE);
HashMap<String, UsbDevice> usbDevices = m.getDeviceList();
Collection<UsbDevice> ite = usbDevices.values();
UsbDevice[] usbs = ite.toArray(new UsbDevice[]{});
for (UsbDevice usb : usbs) {
Log.d("Connected usb devices","Connected usb devices are "+ usb.getDeviceName());
}