Most visited

Recently visited

Added in API level 16

Choreographer

public final class Choreographer
extends Object

java.lang.Object
   ↳ android.view.Choreographer


Coordinates the timing of animations, input and drawing.

The choreographer receives timing pulses (such as vertical synchronization) from the display subsystem then schedules work to occur as part of rendering the next display frame.

Applications typically interact with the choreographer indirectly using higher level abstractions in the animation framework or the view hierarchy. Here are some examples of things you can do using the higher-level APIs.

However, there are a few cases where you might want to use the functions of the choreographer directly in your application. Here are some examples.

Each Looper thread has its own choreographer. Other threads can post callbacks to run on the choreographer but they will run on the Looper to which the choreographer belongs.

Summary

Nested classes

interface Choreographer.FrameCallback

Implement this interface to receive a callback when a new display frame is being rendered. 

Public methods

static Choreographer getInstance()

Gets the choreographer for the calling thread.

void postFrameCallback(Choreographer.FrameCallback callback)

Posts a frame callback to run on the next frame.

void postFrameCallbackDelayed(Choreographer.FrameCallback callback, long delayMillis)

Posts a frame callback to run on the next frame after the specified delay.

void removeFrameCallback(Choreographer.FrameCallback callback)

Removes a previously posted frame callback.

Inherited methods

From class java.lang.Object

Public methods

getInstance

Added in API level 16
Choreographer getInstance ()

Gets the choreographer for the calling thread. Must be called from a thread that already has a Looper associated with it.

Returns
Choreographer The choreographer for this thread.
Throws
IllegalStateException if the thread does not have a looper.

postFrameCallback

Added in API level 16
void postFrameCallback (Choreographer.FrameCallback callback)

Posts a frame callback to run on the next frame.

The callback runs once then is automatically removed.

Parameters
callback Choreographer.FrameCallback: The frame callback to run during the next frame.

See also:

postFrameCallbackDelayed

Added in API level 16
void postFrameCallbackDelayed (Choreographer.FrameCallback callback, 
                long delayMillis)

Posts a frame callback to run on the next frame after the specified delay.

The callback runs once then is automatically removed.

Parameters
callback Choreographer.FrameCallback: The frame callback to run during the next frame.
delayMillis long: The delay time in milliseconds.

See also:

removeFrameCallback

Added in API level 16
void removeFrameCallback (Choreographer.FrameCallback callback)

Removes a previously posted frame callback.

Parameters
callback Choreographer.FrameCallback: The frame callback to remove.

See also:

Hooray!