Stay organized with collections
Save and categorize content based on your preferences.
SurfaceTextureListener
interface SurfaceTextureListener
This listener can be used to be notified when the surface texture associated with this texture view is available.
Summary
Public methods
onSurfaceTextureAvailable
abstract fun onSurfaceTextureAvailable(
surface: SurfaceTexture,
width: Int,
height: Int
): Unit
Invoked when a TextureView
's SurfaceTexture is ready for use.
onSurfaceTextureDestroyed
abstract fun onSurfaceTextureDestroyed(surface: SurfaceTexture): Boolean
Invoked when the specified SurfaceTexture
is about to be destroyed. If returns true, no rendering should happen inside the surface texture after this method is invoked. If returns false, the client needs to call SurfaceTexture.release()
. Most applications should return true.
Parameters |
surface |
SurfaceTexture: The surface about to be destroyed This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# TextureView.SurfaceTextureListener\n\nAdded in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nSurfaceTextureListener\n======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/TextureView.SurfaceTextureListener \"View this page in Java\") \n\n```\ninterface SurfaceTextureListener\n```\n\n|------------------------------------------------------|\n| [android.view.TextureView.SurfaceTextureListener](#) |\n\nThis listener can be used to be notified when the surface texture associated with this texture view is available.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSurfaceTextureAvailable](#onSurfaceTextureAvailable(android.graphics.SurfaceTexture,%20kotlin.Int,%20kotlin.Int))`(`surface:` `[SurfaceTexture](../graphics/SurfaceTexture.html#)`, `width:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `height:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Invoked when a [TextureView](/reference/kotlin/android/view/TextureView)'s SurfaceTexture is ready for use. |\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onSurfaceTextureDestroyed](#onSurfaceTextureDestroyed(android.graphics.SurfaceTexture))`(`surface:` `[SurfaceTexture](../graphics/SurfaceTexture.html#)`)` Invoked when the specified [SurfaceTexture](../graphics/SurfaceTexture.html#) is about to be destroyed. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSurfaceTextureSizeChanged](#onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture,%20kotlin.Int,%20kotlin.Int))`(`surface:` `[SurfaceTexture](../graphics/SurfaceTexture.html#)`, `width:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `height:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Invoked when the [SurfaceTexture](../graphics/SurfaceTexture.html#)'s buffers size changed. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onSurfaceTextureUpdated](#onSurfaceTextureUpdated(android.graphics.SurfaceTexture))`(`surface:` `[SurfaceTexture](../graphics/SurfaceTexture.html#)`)` Invoked when the specified [SurfaceTexture](../graphics/SurfaceTexture.html#) is updated through [SurfaceTexture.updateTexImage()](../graphics/SurfaceTexture.html#updateTexImage()). |\n\nPublic methods\n--------------\n\n### onSurfaceTextureAvailable\n\nAdded in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onSurfaceTextureAvailable(\n surface: SurfaceTexture, \n width: Int, \n height: Int\n): Unit\n```\n\nInvoked when a [TextureView](/reference/kotlin/android/view/TextureView)'s SurfaceTexture is ready for use.\n\n| Parameters ||\n|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `surface` | [SurfaceTexture](../graphics/SurfaceTexture.html#): The surface returned by [android.view.TextureView#getSurfaceTexture()](/reference/kotlin/android/view/TextureView#getSurfaceTexture()) This value cannot be `null`. |\n| `width` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The width of the surface |\n| `height` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The height of the surface |\n\n### onSurfaceTextureDestroyed\n\nAdded in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onSurfaceTextureDestroyed(surface: SurfaceTexture): Boolean\n```\n\nInvoked when the specified [SurfaceTexture](../graphics/SurfaceTexture.html#) is about to be destroyed. If returns true, no rendering should happen inside the surface texture after this method is invoked. If returns false, the client needs to call [SurfaceTexture.release()](../graphics/SurfaceTexture.html#release()). Most applications should return true.\n\n| Parameters ||\n|-----------|--------------------------------------------------------------------------------------------------------------------|\n| `surface` | [SurfaceTexture](../graphics/SurfaceTexture.html#): The surface about to be destroyed This value cannot be `null`. |\n\n### onSurfaceTextureSizeChanged\n\nAdded in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onSurfaceTextureSizeChanged(\n surface: SurfaceTexture, \n width: Int, \n height: Int\n): Unit\n```\n\nInvoked when the [SurfaceTexture](../graphics/SurfaceTexture.html#)'s buffers size changed.\n\n| Parameters ||\n|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `surface` | [SurfaceTexture](../graphics/SurfaceTexture.html#): The surface returned by [android.view.TextureView#getSurfaceTexture()](/reference/kotlin/android/view/TextureView#getSurfaceTexture()) This value cannot be `null`. |\n| `width` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The new width of the surface |\n| `height` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The new height of the surface |\n\n### onSurfaceTextureUpdated\n\nAdded in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onSurfaceTextureUpdated(surface: SurfaceTexture): Unit\n```\n\nInvoked when the specified [SurfaceTexture](../graphics/SurfaceTexture.html#) is updated through [SurfaceTexture.updateTexImage()](../graphics/SurfaceTexture.html#updateTexImage()).\n\n| Parameters ||\n|-----------|-----------------------------------------------------------------------------------------------------------|\n| `surface` | [SurfaceTexture](../graphics/SurfaceTexture.html#): The surface just updated This value cannot be `null`. |"]]