针对 Android api 版本 30 的应用的 Flutter 相机包权限
Flutter camera package permission for the app targeting Android api version 30
我最近将我的一个 flutter 应用程序的 target sdk 升级到了 30。之后,拍照就不能用了。它显示 this link.
中提到的错误
PlatformException(no_available_camera,没有可用于拍照的相机。,null)。
与android中的package visibility changes有关 11.现在第一个link中有一个解决方案,即添加查询设备中安装的所有包的权限通过在清单文件中添加以下行。
<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 清单中添加什么?提前致谢。
如果您的应用面向 Android11(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>
我最近将我的一个 flutter 应用程序的 target sdk 升级到了 30。之后,拍照就不能用了。它显示 this link.
中提到的错误PlatformException(no_available_camera,没有可用于拍照的相机。,null)。
与android中的package visibility changes有关 11.现在第一个link中有一个解决方案,即添加查询设备中安装的所有包的权限通过在清单文件中添加以下行。
<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 清单中添加什么?提前致谢。
如果您的应用面向 Android11(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>