0Pricing
Android Academy · Lesson

Taking Photos

Capture and save an image.

Capturing a Photo

With a preview on screen, the next step is to take a photo. CameRX handles this with the ImageCapture use case.

You'll bind ImageCapture alongside the preview, then call takePicture() when the user taps a shutter button, and save the result to the device gallery.

Building the ImageCapture Use Case

ImageCapture is configured with a builder. A useful option is the capture mode, which trades latency against quality:

  • CAPTURE_MODE_MINIMIZE_LATENCY — fast shutter.
  • CAPTURE_MODE_MAXIMIZE_QUALITY — best image, slightly slower.
val imageCapture = ImageCapture.Builder()
    .setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
    .build()

All lessons in this course

  1. CameraX Overview
  2. Showing a Camera Preview
  3. Taking Photos
  4. Recording Video
← Back to Android Academy