android - ACTION_IMAGE_CAPTURE 和 CAMERA 功能

标签 android camera android-manifest

我正在使用 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/

相关文章:

android - 可以使用传递参数通过 NFC 启动 android 应用程序

android - 在android应用程序中单击后退按钮时如何避免startActivityForResult

android - 从 AndroidManifeast.xml 的元数据访问长 key

Android 和从辅助线程到主线程的调用

java - Android应用程序在旋转屏幕时崩溃

java - 计算高度图上的高度

android - 不断收到预启动报告错误 "Results not available. The devices could not be tested at this time."

android - 在我的应用程序中设置 "android.uid.system"后它无法访问 sdcard?

android - 为什么软键盘继续显示在 View 中?

android - 将预览帧转换为位图