问题
I know that it was supported starting Android 3.1, i mean "how to check hardware support"
回答1:
See: http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_USB_HOST
context.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_USB_HOST);
回答2:
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) {
//...
}
}
}
}
来源:https://stackoverflow.com/questions/15598957/how-to-check-usb-host-support-on-android-device-programmatically