Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/view/Choreographer#nestedclasses) \| [Methods](https://developer.android.com/reference/android/view/Choreographer#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/Choreographer#inhmethods)

# Choreographer

*** ** * ** ***

` public final class Choreographer `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.Choreographer |

<br />

*** ** * ** ***

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.

- To post an animation to be processed on a regular time basis synchronized with display frame rendering, use `https://developer.android.com/reference/android/animation/ValueAnimator#start()`.
- To post a `https://developer.android.com/reference/java/lang/Runnable` to be invoked once at the beginning of the next display frame, use `https://developer.android.com/reference/android/view/View#postOnAnimation(java.lang.Runnable)`.
- To post a `https://developer.android.com/reference/java/lang/Runnable` to be invoked once at the beginning of the next display frame after a delay, use `https://developer.android.com/reference/android/view/View#postOnAnimationDelayed(java.lang.Runnable,%20long)`.
- To post a call to `https://developer.android.com/reference/android/view/View#invalidate()` to occur once at the beginning of the next display frame, use `https://developer.android.com/reference/android/view/View#postInvalidateOnAnimation()` or `https://developer.android.com/reference/android/view/View#postInvalidateOnAnimation(int,%20int,%20int,%20int)`.
- To ensure that the contents of a `https://developer.android.com/reference/android/view/View` scroll smoothly and are drawn in sync with display frame rendering, do nothing. This already happens automatically. `https://developer.android.com/reference/android/view/View#onDraw(android.graphics.Canvas)` will be called at the appropriate time.

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.

- If your application does its rendering in a different thread, possibly using GL, or does not use the animation framework or view hierarchy at all and you want to ensure that it is appropriately synchronized with the display, then use `https://developer.android.com/reference/android/view/Choreographer#postFrameCallback(android.view.Choreographer.FrameCallback)`.
- ... and that's about it.

Each `https://developer.android.com/reference/android/os/Looper` thread has its own choreographer. Other threads can post callbacks to run on the choreographer but they will run on the `https://developer.android.com/reference/android/os/Looper` to which the choreographer belongs.

<br />

## Summary

| ### Nested classes ||
|---|---|
| ` interface` | `https://developer.android.com/reference/android/view/Choreographer.FrameCallback` Implement this interface to receive a callback when a new display frame is being rendered. |
| ` class` | `https://developer.android.com/reference/android/view/Choreographer.FrameData` The payload for `https://developer.android.com/reference/android/view/Choreographer.VsyncCallback` which includes frame information such as when the frame started being rendered, and multiple possible frame timelines and their information including deadline and expected present time. |
| ` class` | `https://developer.android.com/reference/android/view/Choreographer.FrameTimeline` Holds data that describes one possible VSync frame event to render at. |
| ` interface` | `https://developer.android.com/reference/android/view/Choreographer.VsyncCallback` Implement this interface to receive a callback to start the next frame. |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/android/view/Choreographer` | ` https://developer.android.com/reference/android/view/Choreographer#getInstance()() ` Gets the choreographer for the calling thread. |
| ` void` | ` https://developer.android.com/reference/android/view/Choreographer#postFrameCallback(android.view.Choreographer.FrameCallback)(https://developer.android.com/reference/android/view/Choreographer.FrameCallback callback) ` Posts a frame callback to run on the next frame. |
| ` void` | ` https://developer.android.com/reference/android/view/Choreographer#postFrameCallbackDelayed(android.view.Choreographer.FrameCallback,%20long)(https://developer.android.com/reference/android/view/Choreographer.FrameCallback callback, long delayMillis) ` Posts a frame callback to run on the next frame after the specified delay. |
| ` void` | ` https://developer.android.com/reference/android/view/Choreographer#postVsyncCallback(android.view.Choreographer.VsyncCallback)(https://developer.android.com/reference/android/view/Choreographer.VsyncCallback callback) ` Posts a vsync callback to run on the next frame. |
| ` void` | ` https://developer.android.com/reference/android/view/Choreographer#removeFrameCallback(android.view.Choreographer.FrameCallback)(https://developer.android.com/reference/android/view/Choreographer.FrameCallback callback) ` Removes a previously posted frame callback. |
| ` void` | ` https://developer.android.com/reference/android/view/Choreographer#removeVsyncCallback(android.view.Choreographer.VsyncCallback)(https://developer.android.com/reference/android/view/Choreographer.VsyncCallback callback) ` Removes a previously posted vsync callback. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public methods

### getInstance

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Choreographer getInstance ()
```

Gets the choreographer for the calling thread. Must be called from a thread that already has a `https://developer.android.com/reference/android/os/Looper` associated with it.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/Choreographer` | The choreographer for this thread. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException` | if the thread does not have a looper. |

### postFrameCallback

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void postFrameCallback (Choreographer.FrameCallback callback)
```

Posts a frame callback to run on the next frame.

The callback runs once then is automatically removed.

<br />

<br />

| Parameters ||
|---|---|
| `callback` | `Choreographer.FrameCallback`: The frame callback to run during the next frame. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/Choreographer#postFrameCallbackDelayed(android.view.Choreographer.FrameCallback,%20long)`
- `https://developer.android.com/reference/android/view/Choreographer#removeFrameCallback(android.view.Choreographer.FrameCallback)`

### postFrameCallbackDelayed

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public 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.

<br />

<br />

| Parameters ||
|---|---|
| `callback` | `Choreographer.FrameCallback`: The frame callback to run during the next frame. <br /> |
| `delayMillis` | `long`: The delay time in milliseconds. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/Choreographer#postFrameCallback(android.view.Choreographer.FrameCallback)`
- `https://developer.android.com/reference/android/view/Choreographer#removeFrameCallback(android.view.Choreographer.FrameCallback)`

### postVsyncCallback

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void postVsyncCallback (Choreographer.VsyncCallback callback)
```

Posts a vsync callback to run on the next frame.

The callback runs once then is automatically removed.

<br />

<br />

| Parameters ||
|---|---|
| `callback` | `Choreographer.VsyncCallback`: The vsync callback to run during the next frame. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/Choreographer#removeVsyncCallback(android.view.Choreographer.VsyncCallback)`

### removeFrameCallback

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void removeFrameCallback (Choreographer.FrameCallback callback)
```

Removes a previously posted frame callback.

<br />

| Parameters ||
|---|---|
| `callback` | `Choreographer.FrameCallback`: The frame callback to remove. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/Choreographer#postFrameCallback(android.view.Choreographer.FrameCallback)`
- `https://developer.android.com/reference/android/view/Choreographer#postFrameCallbackDelayed(android.view.Choreographer.FrameCallback,%20long)`

### removeVsyncCallback

Added in [API level 33](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void removeVsyncCallback (Choreographer.VsyncCallback callback)
```

Removes a previously posted vsync callback.

<br />

| Parameters ||
|---|---|
| `callback` | `Choreographer.VsyncCallback`: The vsync callback to remove. This value may be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/Choreographer#postVsyncCallback(android.view.Choreographer.VsyncCallback)`