如何解决针对Android api版本30的应用程序的Flutter相机包许可
我最近将我的flutter应用程序的目标sdk升级到了30。此后,无法拍照。它显示了this link中提到的错误。
PlatformException(no_available_camera,没有可用于拍照的相机。,null)。
这与android 11中的package visibility changes有关。现在,第一个链接中有一个解决方案,它通过在清单文件中添加以下行来添加查询设备中安装的所有软件包的权限。
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
哪个为我工作。但是documentation of query_all_packages说:
In the vast majority of cases,however,it's possible to fulfill your app's use cases by
interacting with the set of apps that are visible automatically and by declaring the other
apps that your app needs to access in your manifest file. To respect user privacy,your app
should request the smallest amount of package visibility necessary in order for your app to
work.
In an upcoming policy update,look for Google Play to provide guidelines for apps that need
the QUERY_ALL_PACKAGES permission.
这意味着,仅对于相机应用程序,我们不应要求所有已安装软件包的权限。现在我的问题是,应该在android清单中添加什么以提高相机包的可见性?预先感谢。
解决方法
如果您的应用程序定位到Android 11(API级别30)或更高版本,则系统会自动将某些应用程序显示给您的应用程序,但默认情况下会隐藏其他应用程序。
详细信息可以在这里找到,
https://developer.android.com/training/basics/intents/package-visibility
要使用相机在API级别30和更高级别的设备上拍照,您需要将以下几行添加到清单中,
<queries>
<intent>
<action android:name="android.media.action.IMAGE_CAPTURE" />
</intent>
</queries>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。