PreviewSurfaceCallback

interface PreviewSurfaceCallback
androidx.camera.core.Preview.PreviewSurfaceCallback

A callback to access the Preview Surface.

Summary

Public methods

abstract ListenableFuture<Surface!>
getSurface(@NonNull resolution: Size, imageFormat: Int)

Get preview output Surface with the given resolution and format.

Public methods

getSurface

@NonNull abstract fun getSurface(@NonNull resolution: Size, imageFormat: Int): ListenableFuture<Surface!>

Get preview output Surface with the given resolution and format.

This is called when Preview needs a valid Surface. e.g. when the Preview is bound to lifecycle or the current Surface is no longer valid. When that happens, the implementation is required to create a Surface with the given resolution/format.

The Surface should be released after the use case is no longer active. If released prematurely, the implementation will be asked to provide a new Surface via this method.

Parameters
resolution Size: the resolution required by CameraX.
imageFormat Size: the ImageFormat required by CameraX.
Return
ListenableFuture<Surface!>: A ListenableFuture that contains the user created Surface.