ACTION_IMAGE_CAPTURE 和相机功能
ACTION_IMAGE_CAPTURE and CAMERA feature
我正在使用 ACTION_IMAGE_CAPTURE
请求相机应用拍照。
根据 official doc 如果我的应用使用相机功能但不需要它来正常运行,清单中应保留以下内容
<manifest ... >
<uses-feature android:name="android.hardware.camera"
android:required="false" />
...
</manifest>
我真的不明白在清单中包含这些行的想法是什么,如果没有这个 not 必需的功能,它不是一样的吗?
我想知道写这个有什么意义?我可以安全地从清单中跳过这个吗?
我是否拥有清单中列出的功能并不重要,我仍然可以在 运行 时间内检查它,对吗 hasSystemFeature(PackageManager.FEATURE_CAMERA)
?
来自 Android 文档:
The purpose of a declaration is to inform any external
entity of the set of hardware and software features on which your
application depends.
In general, you should always make sure to declare
elements for all of the features that your application requires
<uses-feature android:name="android.hardware.camera"
android:required="false" />
如果清单中给出了要求 = "false",则应用会使用摄像头,但这并不是应用程序运行所必需的,并且所有设备都可以从 Play 商店安装应用,无论设备是否具有摄像头功能。
如果需要 = "true" 已在清单中给出,则具有摄像头功能的设备只能使用应用程序,其他没有摄像头功能的设备无法从 google Play 商店安装。
这允许 Google Play 商店过滤掉不具备所需功能的设备的应用。
希望对您有所帮助!
不,不一样。正如 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
作为相机。
您可能会通过代码询问,是的。但问题是一些 permissions
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.
因此,如果您想使用某些功能而不想使用其他功能,并且您包含了权限,您可能需要声明您的应用 真的 不需要存在某些设备功能。
我正在使用 ACTION_IMAGE_CAPTURE
请求相机应用拍照。
根据 official doc 如果我的应用使用相机功能但不需要它来正常运行,清单中应保留以下内容
<manifest ... >
<uses-feature android:name="android.hardware.camera"
android:required="false" />
...
</manifest>
我真的不明白在清单中包含这些行的想法是什么,如果没有这个 not 必需的功能,它不是一样的吗?
我想知道写这个有什么意义?我可以安全地从清单中跳过这个吗?
我是否拥有清单中列出的功能并不重要,我仍然可以在 运行 时间内检查它,对吗 hasSystemFeature(PackageManager.FEATURE_CAMERA)
?
来自 Android 文档:
The purpose of a declaration is to inform any external entity of the set of hardware and software features on which your application depends.
In general, you should always make sure to declare elements for all of the features that your application requires
<uses-feature android:name="android.hardware.camera"
android:required="false" />
如果清单中给出了要求 = "false",则应用会使用摄像头,但这并不是应用程序运行所必需的,并且所有设备都可以从 Play 商店安装应用,无论设备是否具有摄像头功能。
如果需要 = "true" 已在清单中给出,则具有摄像头功能的设备只能使用应用程序,其他没有摄像头功能的设备无法从 google Play 商店安装。
这允许 Google Play 商店过滤掉不具备所需功能的设备的应用。
希望对您有所帮助!
不,不一样。正如 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
作为相机。
您可能会通过代码询问,是的。但问题是一些 permissions
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.
因此,如果您想使用某些功能而不想使用其他功能,并且您包含了权限,您可能需要声明您的应用 真的 不需要存在某些设备功能。