gpt4 book ai didi

android - 在 flutter 中访问外部摄像头时出错 - "The user has not given permission to access the device"

转载 作者:行者123 更新时间:2023-12-04 23:45:36 35 4
gpt4 key购买 nike

我想通过我的平板电脑访问 USB 网络摄像头。
我下载了这个项目用于学习和测试目的。它完美地工作。相机打开,拍照并保存。
project - github
我在flutter中创建了一个项目,并建立了一个通信 channel 来访问应用程序。
但是当我尝试打开相机的那一刻,我得到了消息:

User has not given 10404/com.example.monitoramento permission to access device /dev/bus/usb/001/002


我有一个 device_filter.xml 文件,我在其中添加了设备 PID 和 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>

还会报告这些错误。
enter image description here
我很感激任何评论!

最佳答案

与类似的应用程序( https://github.com/shengjunhu/android_uvc_camera )相同的问题。两个应用程序的 UI 看起来都一样,甚至有相同的标题(UVCCamera),这让我怀疑它们与基因有关。
Android 要求应用程序在访问 USB 设备之前获得许可。据我了解,有两种方法可以做到这一点:

  • 为应用定义一个 Intent 过滤器。如果连接了匹配的 USB 设备,则会提示用户允许应用程序访问 USB 设备,然后启动应用程序。在这种情况下,应用程序已经拥有权限。 Intent 过滤器需要一个设备列表来监听,例如device_filter.xml .
  • 如果应用程序扫描设备而不是等待通知,则必须明确获得许可。这很像其他运行时权限,如 https://developer.android.com/guide/topics/connectivity/usb/host.html#permission-d 中所述。 .

  • 如果您的应用程序扫描 USB 摄像头设备而不是监听 Intent ,则第一个选项不可用并修改 device_filter.xml没有效果。发现摄像头后,您必须请求权限并推迟摄像头访问权限,直到获得权限。

    关于android - 在 flutter 中访问外部摄像头时出错 - "The user has not given permission to access the device",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70130204/

    35 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com