Problems with USB camera in android that dont work

263 Views Asked by At

I bought a little usb camera for mlkit but the android see her as usb device and not as usb camera. The strange things is that the apps in Play Store for USB Camera works all. Before to start to learn the UVC I ask help everyone. I have read much posts before ask this.

This code works good, he ask the permission

UsbManager usbManager = (UsbManager) CONTEXT.getSystemService(Context.USB_SERVICE);
                        HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList();
                        if (!deviceList.isEmpty()) {
                            for (UsbDevice usbDevice : deviceList.values()) {
                                if (usbDevice.getVendorId() == 7119 && usbDevice.getProductId() == 49153) {
                                    String ACTION_USB_PERMISSION = "com.android.example.USB_PERMISSION";
                                    PendingIntent permissionIntent = PendingIntent.getBroadcast(CONTEXT, 0, new Intent(ACTION_USB_PERMISSION), PendingIntent.FLAG_MUTABLE);
                                    usbManager.requestPermission(usbDevice, permissionIntent);
                                }
                            }
                        }

this script works good, reports a single device

UsbManager usbManager = (UsbManager) CONTEXT.getSystemService(Context.USB_SERVICE);
        HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList();
        if (!deviceList.isEmpty()) {
            for (UsbDevice usbDevice : deviceList.values()) {
                properties(usbDevice);
            }
        }

getDeviceName: /dev/bus/usb/001/049, getVendorId: 7119, getProductName: USB Camera, getProductId: 49153

but this script dont show the LENS_FACING_EXTERNAL. He find only 2 FRONT camera and 1 BACK (that are the integrated cameras)

CameraManager cameraManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
        String[] CameraIdList = cameraManager.getCameraIdList();
        int mCameraNum = CameraIdList.length;

        for (String cameraId : CameraIdList) {
            CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId);

            Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING);
            String lenFacinngType = "";
            switch (facing) {
                case (CameraCharacteristics.LENS_FACING_EXTERNAL):
                    lenFacinngType = "EXTERNAL";
                    break;
                case (CameraCharacteristics.LENS_FACING_BACK):
                    lenFacinngType = "BACK";
                    break;
                case (CameraCharacteristics.LENS_FACING_FRONT):
                    lenFacinngType = "FRONT";
                    break;
                default:
                    lenFacinngType = "UNK";
                    break;
            }
}
}
0

There are 0 best solutions below