Code example for UsbEndpoint

Methods: getDirection, getType

0
            Log.e(TAG, "could not find endpoint");
            return; 
        } 
        // endpoint should be of type interrupt 
        UsbEndpoint ep = intf.getEndpoint(0);
        if (ep.getType() != UsbConstants.USB_ENDPOINT_XFER_INT
                || ep.getDirection() != UsbConstants.USB_DIR_IN) {
            Log.e(TAG, "endpoint is not Interrupt IN");
            return; 
        } 
        mDevice = device;
        mEndpointIntr = ep;
 
        UsbDeviceConnection connection = mUsbManager.openDevice(device);
        if (connection != null && connection.claimInterface(intf, true)) {
            //Start the polling thread 
            Toast.makeText(this, "open SUCCESS", Toast.LENGTH_SHORT).show();
            mConnection = connection;
            mRunning = true;
            Thread thread = new Thread(null, this, "ScaleMonitor");
            thread.start();