Which Android Camera API should a new project use? - android

I am developing a new app, and I want to support all the way back to Jelly Bean/Ice Cream Sandwich. I need to use the video camera in my app - just to shoot some 15 second footage and no processing.
Do I have to write two camera Activities, one with the camera api and the other with the camera2 api, and somehow pick one based on the api level of the device?
Or, should I just use the camera api?
Which camera api would you use if you were developing a new camera based app today?
Thanks!
Mark

For the near future, the deprecated Camera API will not disappear, even on the cutting-edge new devices. I would recommend to switch to Camera2 if one of the following causes applies:
your app makes good use of some of the new features, e.g. capture-while-recording.
your app has other reasons not to be backwards-compatible under API v.21 (Lollipop), e.g. it only runs on ARM64.
you want to practice or demonstrate your skills with the new API.
PS and I support the first suggestion from SAg: use the Camera Intent if you only need what such intent can provide. A short unprocessed video clip is a good example.

First of all, you need to decide whether you really want to build a customized camera app, or you can use an existing camera app. From your question, I feel that yours is the latter case, and you can simply use an intent to invoke an existing Android camera application.
https://developer.android.com/guide/topics/media/camera.html#intents
If you really want to build your own customized camera app, I suggest that you refer this link:
http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels
And read the following sections:
Application forward compatibility
Application backward compatibility
Selecting a platform version and API Level

Related

Register a custom camera source with the Camera API

I have quite a bit of experience with the camera API, but I could not find any documentation to answer this question...
Most phones already have a front and a back camera. Would it be possible to simulate a 3rd camera via software (probably using a service), and register that with the api?
The idea would be that we define a custom camera, register it with the Api, and then any camera app would be able to get it by looping through the available cameras.
I imagine several cases where we might want this...
There are some external cameras (such as the FLIR thermal camera) that could provide this.
We might want to concatenate the front and back camera images into a single image, and preview that. I know not all phones support opening both cameras concurrently, but some do, and i could imagine this functionality would be cool for 3rd party video chat apps like Skype... Specifically, since Skype doesnt natively support this, by registering directly with the Android Camera Api, we could get around the limitations of the Skype API, since our custom camera would just look like one of the default Android cameras.
So would this be possible? Or what is the technical limitations that prevents us from doing it. Perhaps the Android Api simply doesnt let us define a custom source (I know the Sensor API doesnt, so I would not be surprised if this was the case for the Camera API as well).

Difference Between Camera and Camera2 in Android

I'm building an App which is similar to social media where people can share photos and videos like Instagram. That's why Camera is very important for my app. Now camera2 API is confusing me. I want to run my app on API level 11+ . I know camera2 is only available in API level 21+ So, I need to design two APIs one(camera) for older version and second(camera2) for higher version. Problem is that I just started to learn Android and I do not know what is the main difference between these two APIs.
What main features are available in Camera2 API ?
Or Is there any drawback of Old Camera API ?
I need three things in my App.
1- Simple capture photos
2- Burst pictures (To create GIF Image)
3- Simple video recording.
Which Camera API is good for me ?
The old camera API will work fine for #1 and #3; if you're OK with video-resolution GIFs, you can do #2 as well.
You'll need camera2 (and then devices that support fast, full-resolution capture - see the BURST_CAPTURE capability, or any device that supports the FULL hardware level.), if you want bursts at resolutions above ~1080p.
You can probably start with the CameraView unofficial support library, and modify it as needed. It has support for both APIs, selected based on API level of the device.

Complete Custom Camera2 example

I need to create a custom camera in Android that supports both higher and lower version.I am new to android.I have research a lot I have the code ready for hardware camera i.e. for the api less than 21.But I am finding hard time searching the code that supports camera hardware 2.
The old deprecated camera API still works on Android 21 and above. But you are right, using the new API is preferable, and gives you more options and better performance.
You can start with the official Camera2Basic sample.

How to add a TextView over default camera Application

I am creating an app where the user has to take multiple pictures of an object. I need to guide him through the process by adding a message on top of the screen when the camera is opened (something like: Right side, Left side, Front, etc) Toasts are not good since I need the message to say there until the picture is taken. Is there a way to add a layout over the default camera? I considered creating a camera activity but with android.hardware.Camera deprecated, and my minimum SDK not supporting camera2, it seems quite the predicament.
Any suggestion is appreciated.
Thank you
Is there a way to add a layout over the default camera?
There is no single "default camera". There are several thousand Android device models. There are hundreds of different camera apps that come pre-installed on those device models. Plus, the user may elect to use a different camera app, one that they installed, when you try starting an ACTION_IMAGE_CAPTURE activity (or however you plan on taking a picture). As a result, you have no way of knowing what the UI is of the camera activity to be able to annotate it, even if annotating it were practical (which, on the whole, it isn't).
I considered creating a camera activity but with android.hardware.Camera deprecated, and my minimum SDK not supporting camera2, it seems quite the predicament.
In Android, "deprecated" means "we have something else that we think that you should use". Unless the documentation specifically states that the deprecated stuff does not work starting with such-and-so API level, the deprecated APIs still work. They may not be the best choice, in light of the alternative, but they still work.
In particular, deprecated APIs sometimes are your only option. The camera is a great example. android.hardware.Camera is the only way to take pictures on Android 4.4 and below. At the present time, that still represents the better part of a billion devices. Here, "deprecated" means "on Android 5.0 and higher, you should consider using android.hardware.camera2". Whether you choose to use both APIs (android.hardware.camera2 on API Level 21+ and android.hardware.Camera before then), or whether you choose to use android.hardware.Camera across the board, is your decision to make.
If you want to offer some sort of guided picture-taking, implementing your own camera UI in your own app is pretty much your only choice.

Android Camera with Surfaceview

I want to built my own camera app in android including the following options pinch to zoom and autofocus without using camera intent. I already gone through some samples from Git hub but I couldn't make use of them.So, I decided to start learning Camera API from Google developers. Here I need a complete steps to develop my app and what to learn like camera, surface view and anything else.
Thanks in advance
I have done what you want to be done recently.
For android, there are 2 camera APIs
the camera api
and the camera2 api
camera api is deprecated on android api 21. starting from android api 21, you have to use camera2 api. so you have to learn both of them.
Camera api brother with SurfaceView.
Camera2 api brother with TextureView.
Camera2 api is quit alot different from Camera api, and also is much more complicated than Camera api.
You may want to take a look at my project SimpleCameraView, it is much clear than other projects. I just created this repository yesterday.
Things to Need to Learn to Build Custom Camera APP
Setting Camera,FlashLight and FILE_STORAGE Permissions in Manifest
SurfaceView and How to Use it.
Manual Control of Flash Light.
Lazy Loader for Displaying Images Taken without Memory Leaking.
And you can go through this for Sample : Build Custom Camera

Categories

Resources