Use of camera2 versus deprecated Camera - what is

2019-01-22 19:39发布

问题:

I'm writing an app for which the camera is an essential feature. In this regard I want to be 100% certain about the following aspects:

  1. If I use the deprecated camera: will the app still run on all APIs now?
  2. If 1) is yes: At what point in time this app will not run anymore on all APIs (my app shall cover minimum API 17) ?
  3. Where can I find updated official information about 2), i.e. what is planned and by when?
  4. Say, I would use the new camera2 already now, my understanding is that the app would not run on any API below 21 - correct?
  5. My working hypothesis from the information I got so far is: NOW still use the the deprecated Camera. But Keep watching market shares of APIs and start learning camera2 soon, in order to be ready to switch the app to camera2 within the next 2-3 years. Do you agree?

In any case, the use of a device's camera and making it run on virtually all targeted devices is tricky enough (as for now I am happy to have mastered the "old" Camera...). Therefore, I really want to be sure about the above points. Many thanks for your answers.

回答1:

If I use the deprecated camera: will the app still run on all APIs now?

Yes.

At what point in time this app will not run anymore on all APIs (my app shall cover minimum API 17) ?

Build a time machine, go into the future, find out, and let the rest of us know.

IOW, we have no way of predicting if and when Google might discontinue this API entirely. That being said, they almost never discontinue APIs.

Where can I find updated official information about 2), i.e. what is planned and by when?

Get a job with Google, or go with the aforementioned time machine option. Google is not in the habit of announcing plans in advance, and their time machine is not available for rental.

(though Elon Musk probably has a Tesla outfitted with a Mr. Fusion, so you could reach out to him...)

I would use the new camera2 already now, my understanding is that the app would not run on any API below 21 - correct?

Correct.

NOW still use the the deprecated Camera. But Keep watching market shares of APIs and start learning camera2 soon, in order to be ready to switch the app to camera2 within the next 2-3 years. Do you agree?

No, for reasons I will clarify after your next quote.

the use of a device's camera and making it run on virtually all targeted devices is tricky enough

Part of that trickiness is the fact that device manufacturers have camera implementations that might be generously described as "quirky".

The problem with sticking with the old camera API exclusively is that I expect quality control on that API to steadily decline. What limited resources device manufacturers have for cameras primarily will be devoted to the new API.

Hence, my recommendation is to use both APIs: using camera2 where possible and falling back to the original API where needed. Admittedly, this requires substantially more work. If you are not in position to do that work, then you have no choice but to stick with the original camera API until such time as you are ready to have your minSdkVersion be 21+.