# SurfaceRequest.Result

Artifact: [androidx.camera:camera-core](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/core/SurfaceRequest.java+class:androidx.camera.core.SurfaceRequest.Result) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

*** ** * ** ***


```
@AutoValue
public abstract class SurfaceRequest.Result
```

<br />

*** ** * ** ***

Result of providing a surface to a `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` via `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)`.

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#RESULT_INVALID_SURFACE() = 2` Provided surface could not be used by the camera. |
| `static final int` | `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#RESULT_REQUEST_CANCELLED() = 1` Provided surface was never attached to the camera due to the `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` being cancelled by the camera. |
| `static final int` | `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#RESULT_SURFACE_ALREADY_PROVIDED() = 3` Surface was not attached to the camera through this invocation of `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)` due to the `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` already being complete with a surface. |
| `static final int` | `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#RESULT_SURFACE_USED_SUCCESSFULLY() = 0` Provided surface was successfully used by the camera and eventually detached once no longer needed by the camera. |
| `static final int` | `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#RESULT_WILL_NOT_PROVIDE_SURFACE() = 4` Surface was not attached to the camera through this invocation of `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)` due to the `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` already being marked as "will not provide surface". |

| ### Public methods |
|---|---|
| `abstract int` | `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#getResultCode()()` Returns the result of invoking `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)` with the surface from `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#getSurface()`. |
| `abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Surface.html` | `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#getSurface()()` The surface used to complete a `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` with `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)`. |

## Constants

### RESULT_INVALID_SURFACE

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
public static final int RESULT_INVALID_SURFACE = 2
```

Provided surface could not be used by the camera.

This is likely due to the `https://developer.android.com/reference/android/view/Surface.html` being closed prematurely or the resolution of the surface not matching the resolution specified by `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#getResolution()`.

### RESULT_REQUEST_CANCELLED

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
public static final int RESULT_REQUEST_CANCELLED = 1
```

Provided surface was never attached to the camera due to the `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` being cancelled by the camera.

It is safe to release or reuse `https://developer.android.com/reference/android/view/Surface.html`, assuming it was not previously attached to a camera via `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)`. If reusing the surface for a future surface request, it should be verified that the surface still matches the resolution specified by `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#getResolution()`.

### RESULT_SURFACE_ALREADY_PROVIDED

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
public static final int RESULT_SURFACE_ALREADY_PROVIDED = 3
```

Surface was not attached to the camera through this invocation of `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)` due to the `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` already being complete with a surface.

The `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` has already been completed by a previous invocation of `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)`.

It is safe to release or reuse the `https://developer.android.com/reference/android/view/Surface.html`, assuming it was not previously attached to a camera via `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)`.

### RESULT_SURFACE_USED_SUCCESSFULLY

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
public static final int RESULT_SURFACE_USED_SUCCESSFULLY = 0
```

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 `https://developer.android.com/reference/android/view/Surface.html` and any underlying resources.

For compatibility reasons, the `https://developer.android.com/reference/android/view/Surface.html` object should not be reused by future `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest`, and a new surface should be created instead.

### RESULT_WILL_NOT_PROVIDE_SURFACE

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
public static final int RESULT_WILL_NOT_PROVIDE_SURFACE = 4
```

Surface was not attached to the camera through this invocation of `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)` due to the `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` already being marked as "will not provide surface".

The `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` has already been marked as 'will not provide surface' by a previous invocation of `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#willNotProvideSurface()`.

It is safe to release or reuse the `https://developer.android.com/reference/android/view/Surface.html`, assuming it was not previously attached to a camera via `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)`.

## Public methods

### getResultCode

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
public abstract int getResultCode()
```

Returns the result of invoking `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)` with the surface from `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#getSurface()`.

| Returns |
|---|---|
| `int` | One of `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#RESULT_SURFACE_USED_SUCCESSFULLY()`, `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#RESULT_REQUEST_CANCELLED()`, `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#RESULT_INVALID_SURFACE()`, or `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#RESULT_SURFACE_ALREADY_PROVIDED()`, `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest.Result#RESULT_WILL_NOT_PROVIDE_SURFACE()`. |

### getSurface

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/camera#1.0.0)

```
public abstract @NonNull Surface getSurface()
```

The surface used to complete a `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest` with `https://developer.android.com/reference/androidx/camera/core/SurfaceRequest#provideSurface(android.view.Surface,java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceRequest.Result>)`.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/Surface.html` | the surface. |