List of usage examples for android.hardware.usb UsbManager openAccessory
@RequiresFeature(PackageManager.FEATURE_USB_ACCESSORY)
public ParcelFileDescriptor openAccessory(UsbAccessory accessory)
From source file:nl.bennyjacobs.aapbridge.aap.UsbConnection.java
public UsbConnection(Context context, UsbManager usbManager, UsbAccessory accessory) throws IOException { mContext = context;// w ww . java 2s. c o m mAccessory = accessory; mFileDescriptor = usbManager.openAccessory(accessory); if (mFileDescriptor == null) { throw new IOException("Could not open accessory"); } FileDescriptor fd = mFileDescriptor.getFileDescriptor(); mInputStream = new BufferedInputStream(new FileInputStream(fd)); mOutputStream = new BufferedOutputStream(new FileOutputStream(fd)); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED); //mContext.registerReceiver(mUsbReceiver, filter); }