Md *_*har 3 android user-permissions flutter android-11
我最近将我的一个 flutter 应用程序的目标 sdk 升级到了 30。之后,拍照就不起作用了。它显示了此链接中提到的错误。
PlatformException(no_available_camera,没有可用于拍照的相机。,null)。
这与 android 11 中的包可见性更改有关。现在第一个链接中有一个解决方案,通过在清单文件中添加以下行来添加查询设备中安装的所有包的权限。
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
Run Code Online (Sandbox Code Playgroud)
这对我有用。但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.
Run Code Online (Sandbox Code Playgroud)
这意味着,仅对于相机应用程序,我们不应该请求所有已安装软件包的权限。现在我的问题是,为了相机包的可见性,应该在 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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2267 次 |
| 最近记录: |