Compatibility issues of camera2 api in app - android

I want to open camera in app itself and click pictures automatically when function is called. Camera2 api is not compatible with all devices. I need solution so that the camera should be compatible with all devices. If there is any library that can solve my problem or any other solution?

crammeur gives a good advice:
You can use camera api ( developer.android.com/guide/topics/media/camera ) if your target android api < 21
But there is a bot more:
Actually, you can use the deprecated camera API regardless the target Android API. More than that, I recommend to use this old API for devices that has API >= 21, but feature a Legacy level of camera2 device.
But it is not good to rely on the backwards compatibility layer for devices with native camera2 support. The best practice is to have both solutions in your app, and choose the one that is best for specific device.
You can learn and reuse the code of some open-source libraries in your app, for example CameraKit-Android or Fotoapparat.

Related

Minimum android device specs to use google ml kit

I'm looking for minimum device specs required for an android device to run google ml-kit without any problems. I could not find it on their official website.
Some of them I required to know were :
Architecture
OS
RAM
Min Camera resolution
If I missed anything it's important feel free to add. Thanks.
Theoretically, most ML Kit features support all android os with API level >= 16. Exceptions will be documented in each feature's page. For the camera resolution, it highly depends on each feature and the specific use case, there is no hard requirement so far that applies to all features.

BiometricManager on Android 9

Android 9/Android P (API 28) is said to support facial recognition via BiometricPrompt. All of the tutorials that I've read use BiometricManager for detecting Facial recognition support - but this class wasn't added until API 29 (Android 10/Android Q).
So, how can I detect facial recognition support on API 28?
My preference is to do this without using the AndroidX support library, as I've read conflicting information about what the support library's version of BiometricManager.canAuthenticate() results mean when run on API 28 and lower.
Answering my own question. It appears that even on Android 10 there is no way to find out if the device supports facial recognition, since BiometricManager.canAuthenticate() will return success if the device supports fingerprint auth. From API Docs:
This is the equivalent of canAuthenticate(int) with Authenticators#BIOMETRIC_WEAK
And BiometricManager.canAuthenticate(int) isn't available until API 30.
So using BiometricManager on Android 10 is no different than using the deprecated FingerprintManager.
So working back to my question about BiometricManager support on Android 9. There is no difference between using FingerprintManager and BiometricManager when it is running on an Android 9 device. Therefore the equivalent of BiometricManager is FingerprintManager.
But this doesn't help someone like me that is looking for a way to determine if the device supports facial recognition. There doesn't seem to be any way to determine this pre Android 11.

Android: Minimum API level requirement to use Google Vision API?

I'm working on an Andriod Studio project and I'm trying to use the Google Cloud Vision API. I've been trying to figure out if I can use it since my target sdk is level 15-25, but I can't find the minimum required sdk level anywhere in the documentation.
The only information relevant to this that I found was the only sample application on their website and it says under prerequisites "
An Android device running Android 5.0 or higher 1
That doesn't necessarily mean it doesn't work for lower API levels. Does anyone know what's the minimum requirement?
According to this link vision API depends on the Google Play Services which are curently available for Android 4.0 and above. So for now I think you can continue using the API for your min SDK version 15.
But on a long run there will be many more cool features that will added to lollipop and above only. So the question is, do you want support or quality? Either comprimise the quality for the devices which has 4.0 or focus on quality by building for 5.0 and above because soon devices below 5.0 are going to be obsolete.

Use of camera2 versus deprecated Camera - what is best practice?

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:
If I use the deprecated camera: will the app still run on all APIs
now?
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) ?
Where can I find updated official information about 2), i.e. what is planned and by when?
Say, I would use the new camera2 already now, my understanding is that the app would
not run on any API below 21 - correct?
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.
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+.
Google Just announced CameraX, a API wrapping camera and camera2. This new support API tries to eliminate the quirks each manufacturer added to for our enyojment.
Check it out: https://developer.android.com/training/camerax

Which Android APIs are enough to target maximum number of devices?

I am thinking to make an application but at the time I don't have API 21 and API 22 installed on my SDK due to some network problems and I'm unable to download any thing at the moment. I was wondering if I can make an app effective enough to target many devices without using API 21 and API 22.
Bilal, judging from your comments to others, I'm getting the impression that you don't fully understand how the API levels work in Android. Let me try and explain.
The minimum API level is pretty self-explanatory, as it refers to the minimum Android OS version that can run your app. You want to set this as low as possible to target the most devices. To determine which level you set depends entirely on your application. For example, if your app requires access to the Calendar APIs, your minimum API level would be 7, because that is when those APIs were introduced.
You almost always want to set your maximum API level to the highest possible. Google encourages this, because it allows you to take advantage of all of the new APIs that have been released. But what about the devices that are outdated? You can still enable backwards compatibility with those devices using the Support Library.
Finally, it is not necessary to download each and every API level in the SDK manager. You only need to download the most recent.

Categories

Resources