gpt4 book ai didi

android - ACTION_IMAGE_CAPTURE 和 CAMERA 功能

转载 作者:行者123 更新时间:2023-11-30 01:57:02 24 4
gpt4 key购买 nike

我正在使用 ACTION_IMAGE_CAPTURE 请求相机应用拍照。根据official doc如果我的应用使用相机功能但不需要它来正常运行,则应在 list 中保留以下内容

<manifest ... >
<uses-feature android:name="android.hardware.camera"
android:required="false" />
...
</manifest>

我真的不明白在 list 中包含这些行是什么意思,没有这个不需要必需的功能是不是一样。

我想知道写这个有什么意义?我可以安全地从 list 中跳过这个吗?

如果我有 list 中列出的功能并不重要,我仍然可以在运行时检查它,正确的 hasSystemFeature(PackageManager.FEATURE_CAMERA)

最佳答案

不,这不一样。作为docs说:

The element offers a required attribute that lets you specify whether your application requires and cannot function without the declared feature, or whether it prefers to have the feature but can function without it.

这意味着拥有该功能很好,但没有它应用程序仍然可以工作。例如,一个可以拍照但不需要它作为其正常操作的一部分的应用程序将为相机使用 required=false

您可能会通过代码询问,是的。但问题是一些权限 imply您需要一些特定的硬件:

If an application requests hardware-related permissions, Google Play assumes that the application uses the underlying hardware features and therefore requires those features, even though there might be no corresponding to declarations. For such permissions, Google Play adds the underlying hardware features to the metadata that it stores for the application and sets up filters for them.

For example, if an application requests the CAMERA permission but does not declare a element for android.hardware.camera, Google Play considers that the application requires a camera and should not be shown to users whose devices do not offer a camera.

因此,如果您想要使用某些功能而不是其他功能,并且您包含了权限,您可能想要声明您的应用真的不需要某个设备功能的存在。

关于android - ACTION_IMAGE_CAPTURE 和 CAMERA 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32066364/

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