
Look at all those componentsįirst off, we’ll start with the TextureView. Let’s break down each of them so we can better understand how to use them. The Camera2 API introduces several new interfaces and classes. You will have to deal with checking if the camera permission has been granted or not, but since this topic has been covered widely, we won’t be dealing with that in this article. Now, there are some things we need to add to our manifest file: But in this article, the main focus will be on how to use Camera2. There you will find all the necessary steps you need to take to capture great photos and videos with your camera. If you are interested in doing the former instead of the latter, I'll suggest that you visit the following documentation from Google: The primary reason to use the Camera2 API is if your application requires some custom interaction with the camera or its functionality. Camera2 Use Casesīefore we dive into anything, it is important to understand that if you only want to use the camera to take a picture or to record a video, you do not need to bother yourself with the Camera2 API. So, instead of trying to fill in the missing pieces by yourself, this article will (hopefully) be your one stop shop for interacting with the Camera2 API. There are a ton of resources out there that try to showcase how to use this API directly, but some of them may be outdated and some don’t present the whole picture. This is because the API lets you have in depth control of the camera by exposing various classes that will need to be configured per specific device.Įven if you've dealt with the camera previously, it is such a drastic change from the former camera API, that you might as well forget all that you know. In general, if you want to user the Camera2 API, it would probably be for more than just taking a picture or recording a video. Similar to how there is a way to interact with the microphone or the volume of the device, the Camera2 API gives you the tools to interact with the device's camera. This API and its predecessor were put in place so developers could harness the power of interacting with the camera inside of their applications.



While it has been available since API level 21, the Camera2 API has got to be one of the more complex pieces of architecture developers have to deal with. This distinction is an important one to make. On the other, there is a way to customize your interaction with the camera. On one end, there is a standard way of interacting with the camera. There are even some applications that have integrated the camera as a feature. We all use the camera on our phones and we use it a l-o-t.
