// return true if a device is found boolean askForUSBPermission() { UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE); // register someone to listen for "permission granted" dialogs PendingIntent permissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0); IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION); usbListener = new InfiniTAMUSBPermissionListener(); registerReceiver(usbListener, filter); // get a ist of USB devices HashMap<String, UsbDevice> deviceList = manager.getDeviceList(); Iterator<UsbDevice> deviceIterator = deviceList.values().iterator(); // find the depth camera UsbDevice depthCamera = null; while (deviceIterator.hasNext()) { UsbDevice device = deviceIterator.next(); if ((device.getVendorId() == 0x1d27) && (device.getProductId() == 0x0600)) { depthCamera = device; } } if (depthCamera == null) { usbListener = null; return false; } if (manager.hasPermission(depthCamera)) { usbListener.setDeviceWithPermission(depthCamera); } else { manager.requestPermission(depthCamera, permissionIntent); } return true; }