问题
I am trying to implement a camera app. and checking examples. Some examples contain following manifest feature: uses-feature android:name="android.hardware.camera2.full
.
I have checked official documents and google examples and none of them mentioning existing this feature. (or I am missing some).
What is the source of this feature and what is the difference between android.hardware.camera
?
Edit:
What confuses me was those examples on googlesamples
:
https://github.com/googlesamples/android-Camera2Basic/blob/master/kotlinApp/Application/src/main/AndroidManifest.xml
and this
https://github.com/googlesamples/android-Camera2Basic/blob/master/Application/src/main/AndroidManifest.xml
and this
https://github.com/googlesamples/android-Camera2Raw/blob/master/Application/src/main/AndroidManifest.xml
They are using new Camera2
API and old manifest features
. I don't know how both fits together.
回答1:
As always, it's best to look in Android source code itself:
* A given camera device may provide support at one of two levels: limited or
* full. If a device only supports the limited level, then Camera2 exposes a
* feature set that is roughly equivalent to the older
* {@link android.hardware.Camera Camera} API, although with a cleaner and more
* efficient interface. Devices that implement the full level of support
* provide substantially improved capabilities over the older camera
* API. Applications that target the limited level devices will run unchanged on
* the full-level devices; if your application requires a full-level device for
* proper operation, declare the "android.hardware.camera2.full" feature in your
* manifest.</p>
I hope that clarifies the nature of the feature you mentioned.
As for the camera2
apis - those were introduced in Android 5 (api level 21) as an attempt to create cleaner apis for interaction with the camera as opposed to the old camera
api.
回答2:
The feature flags and the names of the camera APIs aren't actually related, even though they look the same.
The feature "android.hardware.camera" (PackageManager.FEATURE_CAMERA) means that the device has a back-facing camera. That's all; any app that wants to avoid being installed on a device with no back-facing camera needs to list that one.
It's not related to the Java android.hardware.Camera
class.
The feature "android.hardware.camera.level.full" (PackageManager.FEATURE_CAMERA_LEVEL_FULL) says that at least one camera on the device supports the FULL hardware level when used via the android.hardware.camera2
API package.
So a device with a back-facing camera always lists "android.hardware.camera". If it's got a good camera, it'll also list "android.hardware.camera.level.full".
Since the sample apps for camera2 are meant to run on any quality of camera, they only require there to be a camera device, not that it has any particular level of capability.
I've seen some developers try to require a feature like "android.hardware.camera2"; there's no such feature defined in the Android SDK, so trying to require it means your app can't be installed on any device. The camera2 API is always available starting from Android 5.0 (Lollipop); it's just a question of what hardware level each camera device supports (LEGACY, LIMITED, FULL, or LEVEL_3).
回答3:
Android introduced Camera2 api since Android API 21, this new Camera api makes it more usable and easy to change parameters. The previous version was more limited in its capabilities.
Android Camera2 has 4 levels of implementations that depends on the manufacturer:
- Legacy: Its just a conversion between Camera2 and Camera. Just used for compatibility. Just some things of Camera2 work properly.
- Limited: Has Camera2 implementation, but not all the methods that are available. (Not all manufacturers implement the same methods so not everything will work on every device)
- Full: All methods of Camera2 are implemented. Usually manufacturers implement this on their flagship devices.
- Level 3: Additionally support YUV reprocessing and RAW image capture. (BEST CASE)
source here and personal experience.
回答4:
If we just navigate to abstract class in Android studio we will get more clarity it provides the below information
/** *
The CameraDevice class is a representation of a single camera connected to an * Android device, allowing for fine-grain control of image capture and * post-processing at high frame rates.
* *Your application must declare the * {@link android.Manifest.permission#CAMERA Camera} permission in its manifest * in order to access camera devices.
* *A given camera device may provide support at one of two levels: limited or * full. If a device only supports the limited level, then Camera2 exposes a * feature set that is roughly equivalent to the older * {@link android.hardware.Camera Camera} API, although with a cleaner and more * efficient interface. Devices that implement the full level of support * provide substantially improved capabilities over the older camera * API. Applications that target the limited level devices will run unchanged on * the full-level devices; if your application requires a full-level device for * proper operation, declare the "android.hardware.camera.level.full" feature in your * manifest.
* * @see CameraManager#openCamera * @see android.Manifest.permission#CAMERA */ public abstract class CameraDevice implements AutoCloseable {So there no need or I believe nothing which says camera2 and the same as been pointed out by others.
来源:https://stackoverflow.com/questions/48094952/where-does-android-hardware-camera2-full-come-from