# SurfaceControlCallback

Artifact: [androidx.car.app:app-automotive](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/activity/renderer/surface/SurfaceControlCallback.java+class:androidx.car.app.activity.renderer.surface.SurfaceControlCallback) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

*** ** * ** ***


```
public interface SurfaceControlCallback
```

<br />

*** ** * ** ***

A host-side interface for reporting to an off-process renderer events affecting the `https://developer.android.com/reference/android/view/SurfaceView.html` it renders content on.

## Summary

| ### Public methods |
|---|---|
| `default void` | `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceControlCallback#onError(java.lang.String,java.lang.Throwable)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html msg, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/Throwable.html e)` Notifies when there is an error. |
| `abstract void` | `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceControlCallback#onKeyEvent(android.view.KeyEvent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/KeyEvent.html event)` Notifies when `https://developer.android.com/reference/android/view/SurfaceView.html` receives a new key event. |
| `abstract void` | `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceControlCallback#onTouchEvent(android.view.MotionEvent)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/MotionEvent.html event)` Notifies when `https://developer.android.com/reference/android/view/SurfaceView.html` receives a new touch event. |
| `abstract void` | `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceControlCallback#onWindowFocusChanged(boolean,boolean)(boolean hasFocus, boolean isInTouchMode)` Notifies when the window focus changes. |
| `abstract void` | `https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceControlCallback#setSurfaceWrapper(androidx.car.app.activity.renderer.surface.SurfaceWrapper)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/activity/renderer/surface/SurfaceWrapper surfaceWrapper)` Notifies when the underlying surface changes. |

## Public methods

### onError

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
default void onError(@NonNull String msg, @NonNull Throwable e)
```

Notifies when there is an error. Provide default implementation for easier transition.

### onKeyEvent

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
abstract void onKeyEvent(@NonNull KeyEvent event)
```

Notifies when `https://developer.android.com/reference/android/view/SurfaceView.html` receives a new key event.

### onTouchEvent

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
abstract void onTouchEvent(@NonNull MotionEvent event)
```

Notifies when `https://developer.android.com/reference/android/view/SurfaceView.html` receives a new touch event.

### onWindowFocusChanged

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
abstract void onWindowFocusChanged(boolean hasFocus, boolean isInTouchMode)
```

Notifies when the window focus changes.

### setSurfaceWrapper

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.1.0)

```
abstract void setSurfaceWrapper(@NonNull SurfaceWrapper surfaceWrapper)
```

Notifies when the underlying surface changes.