SurfaceRequest.Result

public static abstract class SurfaceRequest.Result
extends Object

java.lang.Object
   ↳ androidx.camera.core.SurfaceRequest.Result


Result of providing a surface to a SurfaceRequest via SurfaceRequest.provideSurface(Surface, Executor, Consumer).

Summary

Constants

int RESULT_INVALID_SURFACE

Provided surface could not be used by the camera.

int RESULT_REQUEST_CANCELLED

Provided surface was never attached to the camera due to the SurfaceRequest being cancelled by the camera.

int RESULT_SURFACE_ALREADY_PROVIDED

Surface was not attached to the camera through this invocation of SurfaceRequest.provideSurface(Surface, Executor, Consumer) due to the SurfaceRequest already being complete with a surface.

int RESULT_SURFACE_USED_SUCCESSFULLY

Provided surface was successfully used by the camera and eventually detached once no longer needed by the camera.

int RESULT_WILL_NOT_PROVIDE_SURFACE

Surface was not attached to the camera through this invocation of SurfaceRequest.provideSurface(Surface, Executor, Consumer) due to the SurfaceRequest already being marked as "will not provide surface".

Public methods

abstract int getResultCode()

Returns the result of invoking SurfaceRequest.provideSurface(Surface, Executor, Consumer) with the surface from getSurface().

abstract Surface getSurface()

The surface used to complete a SurfaceRequest with SurfaceRequest.provideSurface(Surface, Executor, Consumer).

Inherited methods

Constants

RESULT_INVALID_SURFACE

public static final int RESULT_INVALID_SURFACE

Provided surface could not be used by the camera.

This is likely due to the Surface being closed prematurely or the resolution of the surface not matching the resolution specified by SurfaceRequest.getResolution().

Constant Value: 2 (0x00000002)

RESULT_REQUEST_CANCELLED

public static final int RESULT_REQUEST_CANCELLED

Provided surface was never attached to the camera due to the SurfaceRequest being cancelled by the camera.

It is safe to release or reuse Surface, assuming it was not previously attached to a camera via SurfaceRequest.provideSurface(Surface, Executor, Consumer). If reusing the surface for a future surface request, it should be verified that the surface still matches the resolution specified by SurfaceRequest.getResolution().

Constant Value: 1 (0x00000001)

RESULT_SURFACE_ALREADY_PROVIDED

public static final int RESULT_SURFACE_ALREADY_PROVIDED

Surface was not attached to the camera through this invocation of SurfaceRequest.provideSurface(Surface, Executor, Consumer) due to the SurfaceRequest already being complete with a surface.

The SurfaceRequest has already been completed by a previous invocation of SurfaceRequest.provideSurface(Surface, Executor, Consumer).

It is safe to release or reuse the Surface, assuming it was not previously attached to a camera via SurfaceRequest.provideSurface(Surface, Executor, Consumer).

Constant Value: 3 (0x00000003)

RESULT_SURFACE_USED_SUCCESSFULLY

public static final int RESULT_SURFACE_USED_SUCCESSFULLY

Provided surface was successfully used by the camera and eventually detached once no longer needed by the camera.

This result denotes that it is safe to release the Surface and any underlying resources.

For compatibility reasons, the Surface object should not be reused by future SurfaceRequests, and a new surface should be created instead.

Constant Value: 0 (0x00000000)

RESULT_WILL_NOT_PROVIDE_SURFACE

public static final int RESULT_WILL_NOT_PROVIDE_SURFACE

Surface was not attached to the camera through this invocation of SurfaceRequest.provideSurface(Surface, Executor, Consumer) due to the SurfaceRequest already being marked as "will not provide surface".

The SurfaceRequest has already been marked as 'will not provide surface' by a previous invocation of SurfaceRequest.willNotProvideSurface().

It is safe to release or reuse the Surface, assuming it was not previously attached to a camera via SurfaceRequest.provideSurface(Surface, Executor, Consumer).

Constant Value: 4 (0x00000004)

Public methods

getResultCode

public abstract int getResultCode ()

Returns the result of invoking SurfaceRequest.provideSurface(Surface, Executor, Consumer) with the surface from getSurface().

Returns
int One of RESULT_SURFACE_USED_SUCCESSFULLY, RESULT_REQUEST_CANCELLED, RESULT_INVALID_SURFACE, or RESULT_SURFACE_ALREADY_PROVIDED, RESULT_WILL_NOT_PROVIDE_SURFACE.

getSurface

public abstract Surface getSurface ()

The surface used to complete a SurfaceRequest with SurfaceRequest.provideSurface(Surface, Executor, Consumer).

Returns
Surface the surface.