List of usage examples for android.hardware.usb UsbConstants USB_CLASS_VENDOR_SPEC
int USB_CLASS_VENDOR_SPEC
To view the source code for android.hardware.usb UsbConstants USB_CLASS_VENDOR_SPEC.
Click Source Link
From source file:fr.bmartel.android.fadecandy.service.FadecandyService.java
/** * Open USB device & choose USBEndpoint. * * @param device Usb device object.//ww w . j a v a2s . c om * @return Ubs item composed of USBDevice , USBEndpoint & UsbConnection */ private UsbItem openDevice(UsbDevice device) { UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE); try { UsbDeviceConnection connection = manager.openDevice(device); Log.v("USB", "Device name=" + device.getDeviceName()); UsbInterface intf = null; for (int interfaceIndex = 0; interfaceIndex < device.getInterfaceCount(); interfaceIndex++) { UsbInterface usbInterface = device.getInterface(interfaceIndex); if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC) { intf = usbInterface; } } if (intf == null) { intf = device.getInterface(0); } UsbEndpoint endpoint = intf.getEndpoint(0); if (connection != null) { connection.claimInterface(intf, true); } else { Log.e(TAG, "USB connection error"); return null; } return new UsbItem(device, connection, endpoint); } catch (IllegalArgumentException e) { } return null; }