# AndroidExternalSurfaceScope

Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/AndroidExternalSurface.android.kt+class:androidx.compose.foundation.AndroidExternalSurfaceScope) Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.6.0) Common/AllAndroid/JVM
- android

  ```
  interface AndroidExternalSurfaceScope
  ```

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/compose/foundation/AndroidExternalSurfaceScope` is a scoped environment provided when an `https://developer.android.com/reference/kotlin/androidx/compose/foundation/AndroidExternalSurface.composable#AndroidExternalSurface(androidx.compose.ui.Modifier,kotlin.Boolean,androidx.compose.ui.unit.IntSize,androidx.compose.foundation.AndroidExternalSurfaceZOrder,kotlin.Boolean,kotlin.Function1)` or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/AndroidEmbeddedExternalSurface.composable#AndroidEmbeddedExternalSurface(androidx.compose.ui.Modifier,kotlin.Boolean,androidx.compose.ui.unit.IntSize,androidx.compose.ui.graphics.Matrix,kotlin.Function1)` is first initialized. This environment can be used to register a lambda to invoke when a new `https://developer.android.com/reference/android/view/Surface.html` associated with the `https://developer.android.com/reference/kotlin/androidx/compose/foundation/AndroidExternalSurface.composable#AndroidExternalSurface(androidx.compose.ui.Modifier,kotlin.Boolean,androidx.compose.ui.unit.IntSize,androidx.compose.foundation.AndroidExternalSurfaceZOrder,kotlin.Boolean,kotlin.Function1)`/`https://developer.android.com/reference/kotlin/androidx/compose/foundation/AndroidEmbeddedExternalSurface.composable#AndroidEmbeddedExternalSurface(androidx.compose.ui.Modifier,kotlin.Boolean,androidx.compose.ui.unit.IntSize,androidx.compose.ui.graphics.Matrix,kotlin.Function1)` is created.

## Summary

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/AndroidExternalSurfaceScope#onSurface(kotlin.coroutines.SuspendFunction4)(onSurface: suspend https://developer.android.com/reference/kotlin/androidx/compose/foundation/SurfaceCoroutineScope.(surface: https://developer.android.com/reference/android/view/Surface.html, width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Invokes `https://developer.android.com/reference/kotlin/androidx/compose/foundation/AndroidExternalSurfaceScope#onSurface(kotlin.coroutines.SuspendFunction4)` when a new `https://developer.android.com/reference/android/view/Surface.html` is created. | android |

## Public functions

### onSurface

android Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.6.0)

```
fun onSurface(onSurface: suspend SurfaceCoroutineScope.(surface: Surface, width: Int, height: Int) -> Unit): Unit
```

Invokes `https://developer.android.com/reference/kotlin/androidx/compose/foundation/AndroidExternalSurfaceScope#onSurface(kotlin.coroutines.SuspendFunction4)` when a new `https://developer.android.com/reference/android/view/Surface.html` is created. The `https://developer.android.com/reference/kotlin/androidx/compose/foundation/AndroidExternalSurfaceScope#onSurface(kotlin.coroutines.SuspendFunction4)` lambda is invoked on the main thread as part of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/SurfaceCoroutineScope` to provide a coroutine context. Always invoked on the main thread.

| Parameters |
|---|---|
| `onSurface: suspend https://developer.android.com/reference/kotlin/androidx/compose/foundation/SurfaceCoroutineScope.(surface: https://developer.android.com/reference/android/view/Surface.html, width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Callback invoked when a new `https://developer.android.com/reference/android/view/Surface.html` is created. The initial dimensions of the surface are provided. |