Callback2
interface Callback2 : SurfaceHolder.Callback
Known Direct Subclasses
GLSurfaceView |
An implementation of SurfaceView that uses the dedicated surface for displaying OpenGL rendering.
|
NativeActivity |
Convenience for implementing an activity that will be implemented purely in native code.
|
|
Additional callbacks that can be received for Callback
.
Summary
Public methods |
abstract Unit |
Called when the application needs to redraw the content of its surface, after it is resized or for some other reason.
|
open Unit |
An alternative to surfaceRedrawNeeded where it is not required to block until the redraw is complete.
|
Inherited functions |
From class Callback
Unit |
surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int)
This is called immediately after any structural changes (format or size) have been made to the surface. You should at this point update the imagery in the surface. This method is always called at least once, after surfaceCreated .
|
Unit |
surfaceCreated(holder: SurfaceHolder)
This is called immediately after the surface is first created. Implementations of this should start up whatever rendering code they desire. Note that only one thread can ever draw into a Surface , so you should not draw into the Surface here if your normal rendering will be in another thread.
|
Unit |
surfaceDestroyed(holder: SurfaceHolder)
This is called immediately before a surface is being destroyed. After returning from this call, you should no longer try to access this surface. If you have a rendering thread that directly accesses the surface, you must ensure that thread is no longer touching the Surface before returning from this function.
|
|
Public methods
surfaceRedrawNeeded
abstract fun surfaceRedrawNeeded(holder: SurfaceHolder): Unit
Called when the application needs to redraw the content of its surface, after it is resized or for some other reason. By not returning from here until the redraw is complete, you can ensure that the user will not see your surface in a bad state (at its new size before it has been correctly drawn that way). This will typically be preceeded by a call to surfaceChanged
. As of O, surfaceRedrawNeededAsync
may be implemented to provide a non-blocking implementation. If surfaceRedrawNeededAsync
is not implemented, then this will be called instead.
Parameters |
holder |
SurfaceHolder: The SurfaceHolder whose surface has changed. This value cannot be null . |
surfaceRedrawNeededAsync
open fun surfaceRedrawNeededAsync(
holder: SurfaceHolder,
drawingFinished: Runnable
): Unit
An alternative to surfaceRedrawNeeded where it is not required to block until the redraw is complete. You should initiate the redraw, and return, later invoking drawingFinished when your redraw is complete. This can be useful to avoid blocking your main application thread on rendering. As of O, if this is implemented surfaceRedrawNeeded
will not be called. However it is still recommended to implement surfaceRedrawNeeded
for compatibility with older versions of the platform.
Parameters |
holder |
SurfaceHolder: The SurfaceHolder which needs redrawing. This value cannot be null . |
drawingFinished |
Runnable: A runnable to signal completion. This may be invoked from any thread. 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."],[],[]]