3

I know that it was supported starting Android 3.1, i mean "how to check hardware support"

4ntoine
  • 19,816
  • 21
  • 96
  • 220
  • 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 Answers2

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
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