I am developing an application, which uses a usb device through Usb host mode. I use an IntentFilter for ACTION_USB_DEVICE_ATTACHED, so I can connect and communicate with the device after it is attached. The problem occurs when I turn in (or reboot) the phone with the usb device already plugged in. When I open my application after turning on, I cannot see the device.
The following code results in an empty deviceList.
usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList();
The Android Developers Reference says about the getDeviceList():
The result will be empty if no devices are attached, or if USB host mode is inactive or unsupported.
USB host mode is obviously supported on the phone, and a device is attached too. So I guess the host mode is inactive by default.
If I disconnect and reattach the usb device, it works perfectly, but because the device and the phone is in a custom-made holder together, reconnecting them is a bit complicated. Is there a way to activate the host mode from code?