Does android.hardware.Camera still works on all API levels? - android

I am going to be making a camera application, really simple, just add some new interface to the camera app, so nothing fancy, and I was wondering if I could still use the old android.hardware.Camera api since it is simpler and easier to use.

Yes, you should have no problem with this portion of your project.

It might. But...
The android.hardware.camera2 package provides an interface to individual camera devices connected to an Android device. It replaces the deprecated Camera class. - Source
It was deprecated as of API 21

Related

"android.hardware.camera is deprecated" : Can I import the source to project directory?

It is known that android.hardware.camera is deprecated and no longer available for new versions. What if I want to use it rather than going for new camera api? Is there a way to import the source code of the same to my local project directory?
What if I want to use it rather than going for new camera api?
Just use it. "Deprecated" means "we have something else that we recommend that you use". In this case, the original Camera API is still there, and it is your only option on API Level 19 and older.
Just bear in mind that manufacturer support for the Camera API will decline steadily over time, just because probably they won't spend as much engineering and Q&A time on it. By 2018, when Android 5.0+ has 90+% of the market, apps should be using the new camera2 API pretty much exclusively.
Is there a way to import the source code of the same to my local project directory?
No, and you don't need it, as it is part of the Android SDK, the same as everything else in the Android SDK.
If your device does not support the old interface, you have no choice but work with camera2, because these two APIs are based on completely different hardware abstraction level (HAL) and cannot be cross-ported to the other. This is why the new non-backward-compatible API was introduced.

API usage dilemma for my new Android App

I am planning to develop a new Android app with a camera use case in it. Reading the API documentation it seems like Android's 'Camera.hardware' class has been deprecated and new 'android.hardware.camera2' has been introduced. So my question is should which API should I start making my app with? Is it a good idea to start developing my app with the deprecated API, so in that case at least I am not restricted to just Android L? And then later once I get good traction, use the new Camera APIs. Will the old APIs work for Android L too ? What would be a good strategy?
The old android.hardware.Camera is deprecated, this means that it still works (i've tryed it) but there are new API that works better.
However Camera probably has everything you need, so I would recommend to use it because you will have compatibility with every android version.
When let's say an Object is deprecated,doesn't mean it's not going to work in your app.

Intergrate camera without deprecated methods and backwards support

I want to build an application where the front camera of the device is used to project the current image to a SurfaceView. All the tutorials I found so far implement this by using a Camera object from the android.hardware package.
This method, however, seems to be deprecated. When trying the 'new' preferred way to implement this feature following the Android documentation, I get the warning it can only be used with API level 21, which is pretty useless.
So I would like to know the currently preferred way to implement camera functionality in an application. Or is there maybe some support library for API levels lower than 21?
Thanks in advance.
Deprecated interface does not mean you should not use it. It means you should know that it will be phasing out in the future.
As a general rule, it is better to use a newer interface if possible, in order to avoid the need to update the software later.
The fact that API level 21 does not yet have a large enough market share means that you are probably better off using the old interface for now, and keep in mind that in a year or two, you may need to update the implementation.
I think you can implement the camera function in both sets of API and check the device`s build version first then decided to call which one implementation.
eg:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
openCameraNewAPI();
}else{
openCameraOldAPI();
}

Can we use EffectFactory Class for lower versions

For my new assignment, I wanted to use some library that can provide a "Posterize effect". I found many library like Aviary SDK and jhlabs, Yes, these are easy to use, but these making the code heavier. SO I keep searching for Android's API itself which can do the similar task. And after a lot of RnD, I finally found one my time saver class EffectsFactory which provides the same as I wanted. I applied it in my assignment also. But the bad thing it was added in API level 14, And my app should be compatible with at least API level 8.
So, My question is,
Can I use EffectsFactory class for lower version? If Yes then How?
Or, If No, Then Do we have any API in Android SDK itself which do similar to effectfactory ?
Please avoid referencing any library or NDK's open cv library.
No, there is not an Android API that will posterize an image below API 14. Even above API 14 EffectsFactory may not work, as it says in the Android documentation:
Some effects may not be available on all platforms, so before creating a certain effect, the application should confirm that the effect is supported on this platform by calling isEffectSupported(String).
However, you could easily make a lightweight solution yourself. Posterization is a simple process. For example, the code behind JHlabs' posterize filter is less than 50 lines (and most of them are sugar). In your shoes, if using a 3rd party library was out of the question, I wouldn't hesitate to write my own.
Edit: If you happen to be posterizing images your app takes from the camera, there is also Camera.Parameters.setColorEffect(), but again this is not supported on all devices, as it says in the documentation:
For example, the application should call getSupportedColorEffects() before calling setColorEffect(String).

Android Equalizer for API Level < 9

I'm looking for a way to use an equalizer within my app which does not rely on the
android.media.audiofx package especially android.media.audiofx. Equalizer class because these are only available for api level > 9.
Does anybody know about native libraries which work well under android? I've found mpg123 but it seems that this library is very slow. Or is there even another way to implement an equalizer without native librarys?
I did quite a bit of research on this and found that you would have to likely rewrite the entire AudioTrack library in order to accomplish this.
It would require heavy DSP which would be best accomplished using the NDK, if you really want to do it.
Otherwise, I would just write a wrapper that tells the application which API level you're in, and disable those features.
Here is the abstract I wrote on this problem:
http://isthisonthetest.com/?q=node/12
Hope this helps!
EDIT:
This link has been getting a few hits (and the link was broken), so I redirected it to a blog post I just made with the original text. The URL above should work now.

Categories

Resources