Code example for UsbManager

Methods: openAccessory

0
		new Accessory(callback, usbManager, accessory);
	} 
 
	private Accessory(OnAccessoryCallback callback, UsbManager usbManager,
			UsbAccessory accessory) throws IllegalStateException {
		mParcelFileDescriptor = usbManager.openAccessory(accessory);
		if (mParcelFileDescriptor == null) {
			Log.e(TAG, "accessory open failed");
			throw new IllegalStateException();
		} 
		FileDescriptor fd = mParcelFileDescriptor.getFileDescriptor();
		mInputStream = new FileInputStream(fd);
		mOutputStream = new FileOutputStream(fd);
 
		new LooperThread().start();
 
		callback.onAccessoryConnected(this);
	} 
 
	public void write(byte... data) throws IOException {
		mOutputStream.write(data);