public interface

ImageCapture.OnImageSavedCallback

 androidx.camera.core.ImageCapture.OnImageSavedCallback

Overview

Listener containing callbacks for image file I/O events.

Summary

Methods
public voidonCaptureProcessProgressed(int progress)

Callback to report the progress of the capture's processing.

public voidonCaptureStarted()

Called when the capture is started.

public voidonError(ImageCaptureException exception)

Called when an error occurs while attempting to save an image.

public voidonImageSaved(ImageCapture.OutputFileResults outputFileResults)

Called when an image has been successfully saved.

public voidonPostviewBitmapAvailable(Bitmap bitmap)

Callback to notify that the postview bitmap is available.

Methods

public void onCaptureStarted()

Called when the capture is started.

This callback is guaranteed to be called once and before ImageCapture.OnImageSavedCallback for the same invocation of ImageCapture.takePicture(ImageCapture.OutputFileOptions, Executor, ImageCapture.OnImageSavedCallback).

It's recommended to play shutter sound or trigger UI indicators of capture when receiving this callback.

public void onImageSaved(ImageCapture.OutputFileResults outputFileResults)

Called when an image has been successfully saved.

public void onError(ImageCaptureException exception)

Called when an error occurs while attempting to save an image.

Parameters:

exception: An ImageCaptureException that contains the type of error, the error message and the throwable that caused it.

public void onCaptureProcessProgressed(int progress)

Callback to report the progress of the capture's processing.

To know in advanced if this callback will be invoked or not, check the capabilities by ImageCapture.getImageCaptureCapabilities(CameraInfo) and ImageCaptureCapabilities.isCaptureProcessProgressSupported(). If supported, this callback will be called multiple times with monotonically increasing values. At the minimum the callback will be called once with value 100 to indicate the processing is finished. This callback will always be called before ImageCapture.OnImageSavedCallback.

Parameters:

progress: the progress ranging from 0 to 100.

public void onPostviewBitmapAvailable(Bitmap bitmap)

Callback to notify that the postview bitmap is available. The postview is intended to be shown on UI before the long-processing capture is completed in order to provide a better UX.

The postview is only available when the ImageCaptureCapabilities.isPostviewSupported() returns true for the specified CameraInfo and applications must explicitly enable the postview using the ImageCapture.OutputFileOptions.Builder. This callback will be called before ImageCapture.OnImageSavedCallback. But if something goes wrong when processing the postview, this callback method could be skipped.

The bitmap is rotated according to the target rotation set to the ImageCapture to make it upright. If target rotation is not set, the display rotation is used.

See also ImageCapture.Builder.setTargetRotation(int) and ImageCapture.setTargetRotation(int).

Parameters:

bitmap: the postview bitmap.