I know that it was supported starting Android 3.1, i mean "how to check hardware support"
Asked
Active
Viewed 2,902 times
3
-
Curious if there had been a resolution that you had discovered. Didn't have much luck searching within the forums for it. Had this thought for part of an SDK that would like to know, but probably wouldn't want an exclusion of the app on the store if it was lacking the capability. – Jay Snayder Feb 24 '14 at 13:48
2 Answers
2
See: http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_USB_HOST
context.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_USB_HOST);

GabrielWeis
- 340
- 1
- 3
- 13
-
-
2Please add some explanation in your answer as how and why does it solve the problem.. As it is, it is useless to others – LcSalazar Feb 11 '15 at 15:19
0
I had the same question and after some googling I found this: http://android.serverbox.ch/?p=549
In summary, your app needs to use the UsbManager system service and enumerate through attached USB devices.
mUsbManager = (UsbManager) mApplicationContext.getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> devlist = mUsbManager.getDeviceList();
Iterator<UsbDevice> deviter = devlist.values().iterator();
while (deviter.hasNext()) {
UsbDevice d = deviter.next();
if (mUsbManager.hasPermission(d)) {
UsbInterface usbIf = mDevice.getInterface(1);
for (int i = 0; i < usbIf.getEndpointCount(); i++) {
if (usbIf.getEndpoint(i).getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
//...
}
}
}
}

Peter Tran
- 1,626
- 1
- 17
- 26
-
if your device does not support usb host, you will have empty usb devices list. so it seems that your solution does not work – 4ntoine Oct 30 '13 at 07:49
-
Ah...I misunderstood the question. So are you asking how to check USB Host support before any USB devices are plugged in? – Peter Tran Oct 30 '13 at 19:57
-
Of coarse, it depends on android device hardware possibilities, but not on attached usb devices – 4ntoine Oct 31 '13 at 07:50
-
Any ways to find if the device has USB Host support before any USB devices are plugged in? – Navya Ramesan Sep 01 '16 at 05:48
-
Have you tried the answer above (querying for 'PackageManager.FEATURE_USB_HOST')? – Peter Tran Sep 02 '16 at 06:16