---
title: "AndroidExternalSurfaceScope"
description: "[AndroidExternalSurfaceScope] is a scoped environment provided when an [AndroidExternalSurface]
or [AndroidEmbeddedExternalSurface] is first initialized. This environment can be used to
register a lambda to invoke when a new [Surface] associated with the
[AndroidExternalSurface]/[AndroidEmbeddedExternalSurface] is created."
type: "interface"
---

<div class='type'>Interface</div>


<a id='references'></a>

<div class='sourceset sourceset-android'>Android</div>



```kotlin
interface AndroidExternalSurfaceScope
```


`AndroidExternalSurfaceScope` is a scoped environment provided when an `AndroidExternalSurface`
or `AndroidEmbeddedExternalSurface` is first initialized. This environment can be used to
register a lambda to invoke when a new `Surface` associated with the
`AndroidExternalSurface`/`AndroidEmbeddedExternalSurface` is created.


## Functions

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


Invokes `onSurface` when a new `Surface` is created. The `onSurface` lambda is invoked on the
main thread as part of a `SurfaceCoroutineScope` to provide a coroutine context. Always
invoked on the main thread.

#### Parameters

| | |
| --- | --- |
| onSurface | Callback invoked when a new `Surface` is created. The initial dimensions of the surface are provided. |




