'Error accessing external camera in flutter - "The user has not given permission to access the device"
I want to access a USB webcam through my tablet.
I downloaded this project for study and testing purposes. It works perfectly. The camera opens, takes a picture and saves.
I created a project in flutter and made a communication channel to access the application. But the moment I try to open the camera, I get the message:
User has not given 10404/com.example.monitoramento permission to access device /dev/bus/usb/001/002
I have a device_filter.xml file where I add the device PID and VID:
<?xml version="1.0" encoding="utf-8"?>
<usb>
<usb-device class="239" subclass="2" /> <!-- all device of UVC -->
<!-- a few android 9.0 -->
<usb-device class="14" subclass="9" />
<usb-device class="2" subclass="0" />
<usb-device class="6" subclass="-1" />
<usb-device class="39" subclass="0" />
<usb-device product-id="4836" vendor-id="9573" />
<usb-device product-id="2229" vendor-id="1133" />
<usb-device product-id="640" vendor-id="1409" />
<usb-device product-id="258" vendor-id="9228" />
<usb-device product-id="2074" vendor-id="1133" />
</usb>
These errors are also reported.

I appreciate any comments!
Solution 1:[1]
Same issue here with a similar app (https://github.com/shengjunhu/android_uvc_camera). The UI looks the same for both apps and even has the same title (UVCCamera), leading me to suspect they are genetically related.
Android requires that apps obtain permission before accessing a USB device. As I understand it, There are two ways to do this:
Define an intent filter for the app. If a matching USB device is connected, the user is prompted to allow the app to access the USB device, then the app is launched. In this case, the app has permission already. The intent filter needs a list of devices to listen for, such as
device_filter.xml.If the app scans for the device rather than wait for a notification, permission must be obtained explicitly. This works much like for other runtime permissions, as described in https://developer.android.com/guide/topics/connectivity/usb/host.html#permission-d.
If your app scans for USB camera devices rather than listening for an intent, the first option is not available and modifying device_filter.xml has no effect. Upon discovering a camera, you will have to request the permission and defer camera access until the permission is granted.
Solution 2:[2]
What I understand from your question that there is a problem with camera permission so there is a question similar to yours that has be answered. so take a look:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user149408 |
| Solution 2 | Mohammad Sami |
