# SurfaceOutput.Event

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/SurfaceOutput.java+class:androidx.camera.core.SurfaceOutput.Event) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/camera#1.3.0)

*** ** * ** ***

<br />

```
@AutoValue
public abstract class SurfaceOutput.Event
```

<br />

*** ** * ** ***

Events of the `https://developer.android.com/reference/android/view/Surface.html` retrieved from `https://developer.android.com/reference/androidx/camera/core/SurfaceOutput#getSurface(java.util.concurrent.Executor,androidx.core.util.Consumer<androidx.camera.core.SurfaceOutput.Event>)`.

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/camera/core/SurfaceOutput.Event#EVENT_REQUEST_CLOSE() = 0` The `https://developer.android.com/reference/android/view/Surface.html` provider is requesting to release the `https://developer.android.com/reference/android/view/Surface.html`. |

| ### Public methods |
|---|---|
| `abstract int` | `https://developer.android.com/reference/androidx/camera/core/SurfaceOutput.Event#getEventCode()()` Returns the event associated with the `https://developer.android.com/reference/androidx/camera/core/SurfaceOutput`. |
| `abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/camera/core/SurfaceOutput` | `https://developer.android.com/reference/androidx/camera/core/SurfaceOutput.Event#getSurfaceOutput()()` Gets the `https://developer.android.com/reference/androidx/camera/core/SurfaceOutput` associated with this event. |

## Constants

### EVENT_REQUEST_CLOSE

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

```
public static final int EVENT_REQUEST_CLOSE = 0
```

The `https://developer.android.com/reference/android/view/Surface.html` provider is requesting to release the `https://developer.android.com/reference/android/view/Surface.html`.

Releasing a `https://developer.android.com/reference/android/view/Surface.html` while it's still being written into is not safe on some devices. This is why the provider of the `https://developer.android.com/reference/android/view/Surface.html` will not release the `https://developer.android.com/reference/android/view/Surface.html` without the CameraX's permission. Once this event is received, the implementation should stop accessing the `https://developer.android.com/reference/android/view/Surface.html` as soon as possible, then mark the `https://developer.android.com/reference/androidx/camera/core/SurfaceOutput` as closed by calling `https://developer.android.com/reference/androidx/camera/core/SurfaceOutput#close()`. Once closed, CameraX will notify the `https://developer.android.com/reference/android/view/Surface.html` provider that it's safe to release the `https://developer.android.com/reference/android/view/Surface.html`.

## Public methods

### getEventCode

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

```
public abstract int getEventCode()
```

Returns the event associated with the `https://developer.android.com/reference/androidx/camera/core/SurfaceOutput`.

### getSurfaceOutput

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

```
public abstract @NonNull SurfaceOutput getSurfaceOutput()
```

Gets the `https://developer.android.com/reference/androidx/camera/core/SurfaceOutput` associated with this event.