Android Jetpack: CameraX Beta

Android Jetpack: CameraX Beta
2 min read
23 April 2020

CameraX is a jet-pack support library created to make camera app development easier. And now it's in beta.

The CameraX API is built on top of the Camera2 API, and leverages its capabilities. However, it uses a simpler, use-case-based approach that is lifecycle aware.

Best of all, this concise API results in an average of 70% fewer lines of code than the Camera2 API.

CameraX focuses on use cases to allow you to focus on the task you need to get done. These are the main use cases that we have identified

  • Preview, which enables you to include a viewfinder showing a live camera feed in your app.
  • Image analysis, which enables you to access camera frame data to implement features such as object detection and augmented reality.
  • Image capture, which enables you to take a picture and save it to a disk.

Video capture is not officially supported yet, but we will release a blog post when it's done. 

The API also lets you easily implement top to focus, zoom control, device rotation, and flash.

This API includes access to vendor specific extensions, including portrait, beauty, HDR, and night mode on certain devices such as Samsung, Motorola, and oppo. Android Jetpack: CameraX BetaSince it's built on top of the Camera2 API, this API is backwards compatible to L, which covers over 90% of devices and eliminates the need for code blocks to check for which API version the app is running.

This API provides consistent behavior across a wide variety of devices so that you don't have to check what kind of phone it is. This is done through the extensive test lab that has the equivalent of 400 million devices.

This lab uses unit tests and end-to-end tests in order to accommodate camera inconsistencies so you can focus on your app. If you discover a device that does fail, you can file a bug at the Issue Tracker.

We have resources to help you get started, like extensive documentation, a sample app, a code lab, a Stack Overflow tag, and mailing lists.

The sample app on GitHub is a basic photography app and supports all three use cases. Try out CameraX, and let us know how you like it.

Alex 10.6K
Joined: 4 years ago
In case you have found a mistake in the text, please send a message to the author by selecting the mistake and pressing Ctrl-Enter.
Comments (0)

    No comments yet

You must be logged in to comment.

Sign In / Sign Up