如何使用Android的相机或摄像机2 API来支持无德precation笔记新旧版本的API? [英] How to use Android's camera or camera2 API to support old and new API versions without deprecation notes?

查看:174
本文介绍了如何使用Android的相机或摄像机2 API来支持无德precation笔记新旧版本的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的摄像机2 API混淆了我。我想开发一个应用程序的(针对Android API的10 - 21)即使用设备的摄像头。如前所述<一个href=\"https://developer.android.com/reference/android/hardware/camera2/package-summary.html\">here,我应该使用相机API。

The new camera2 API confuses me. I want to develop an app (for Android APIs 10 - 21) which uses the device's camera. As stated here, I should use the "Camera" API.

然而,当我尝试将摄像机API的(android.hardware.Camera)的增加​​清单的用户功能,的它被标记为德precated 。在另一方面,我不能将其更改为摄像机2API的(android.hardware.camera2)的,因为它是唯一与Android兼容的API 21+(Android的5 - 棒棒堂) - 本来认为这与太多,但我只能加2链接。

However, when I try to add the "Camera" API (android.hardware.Camera) to the manifest's user features, it is marked as deprecated. On the other hand, I cannot change it to the "camera2" API (android.hardware.camera2) since it is only compatible with Android API 21+ (Android 5 - Lollipop) - Would have linked it too, but I can only add 2 links.

不仅我想我的应用程序在旧版Android的运行,也是最新的一个...

Not only do I want my app to run on older versions of Android, but also the newest one...

推荐答案

虽然老相机API被标记为pcated德$ P $,它仍然是全功能的,并且将继续这样做相当长一段时间(如几乎所有的相机使用的Play商店应用程序使用它目前)。

Even though the old camera API is marked as deprecated, it is still fully functional, and will remain so for quite a while (as nearly all camera-using applications on the Play Store use it currently).

您要忽略它是pcated德$ P $的Andr​​oid Studio的投诉,但如果你想比21支持Android版本早,你必须使用旧的API。

You'll have to ignore Android Studio's complaints about it being deprecated, but if you want to support Android versions earlier than 21, you have to use the old API.

在API级别21,你当然可以使用新的API和它的新功能,但目前你有,如果你的API之间进行切换,以保持您的应用程序一个完全独立的流程。不幸的是,这两种API有不同的足够的世界观,它很难写一个支持库,它可以让你使用像新的API旧设备上,以及(其中来自新的API库映射到旧的API,如果不是在API 21 +)。

On API level 21, you can certainly use the new API and its new features, but currently you'll have to maintain a wholly separate flow in your app if you switch between the APIs. Unfortunately, the two APIs have a different enough of a worldview that it's hard to write a support library that would let you use something like the new API on older devices as well (where the library maps from the new API to the old API if not on API 21+).

这篇关于如何使用Android的相机或摄像机2 API来支持无德precation笔记新旧版本的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆