Code example for UsbDeviceConnection

Methods: closecontrolTransfer

0
    private static final int LENGTH = 64;
    private void getDeviceStatus(UsbDevice device) {
        UsbDeviceConnection connection = mUsbManager.openDevice(device);
        //Create a sufficiently large buffer for incoming data 
        byte[] buffer = new byte[LENGTH];
        connection.controlTransfer(REQUEST_TYPE, REQUEST, REQ_VALUE, REQ_INDEX,
                buffer, LENGTH, 2000);
        //Parse received data into a description 
        String description = parseConfigDescriptor(buffer);
         
        mDisplayText.setText(description);
        connection.close();
    } 
     
    /* 
     * Parse the USB configuration descriptor response per the 
     * USB Specification.  Return a printable description of 
     * the connected device. 
     */ 
    private static final int DESC_SIZE_CONFIG = 9;
Contextual code suggestions in your IDE  Get Codota for Java