Stay organized with collections
Save and categorize content based on your preferences.
Choreographer.FrameCallback
public
static
interface
Choreographer.FrameCallback
android.view.Choreographer.FrameCallback
|
Implement this interface to receive a callback when a new display frame is
being rendered. The callback is invoked on the Looper
thread to
which the Choreographer
is attached.
Summary
Public methods |
abstract
void
|
doFrame(long frameTimeNanos)
Called when a new display frame is being rendered.
|
Public methods
doFrame
public abstract void doFrame (long frameTimeNanos)
Called when a new display frame is being rendered.
This method provides the time in nanoseconds when the frame started being rendered.
The frame time provides a stable time base for synchronizing animations
and drawing. It should be used instead of SystemClock.uptimeMillis()
or System.nanoTime()
for animations and drawing in the UI. Using the frame
time helps to reduce inter-frame jitter because the frame time is fixed at the time
the frame was scheduled to start, regardless of when the animations or drawing
callback actually runs. All callbacks that run as part of rendering a frame will
observe the same frame time so using the frame time also helps to synchronize effects
that are performed by different callbacks.
Please note that the framework already takes care to process animations and
drawing using the frame time as a stable time base. Most applications should
not need to use the frame time information directly.
Parameters |
frameTimeNanos |
long : The time in nanoseconds when the frame started being rendered,
in the System.nanoTime() timebase. Divide this value by 1000000
to convert it to the SystemClock.uptimeMillis() time base. |
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Choreographer.FrameCallback\n\nAdded in [API level 16](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nChoreographer.FrameCallback\n===========================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/view/Choreographer.FrameCallback \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nChoreographer.FrameCallback\n`\n\n\n`\n\n\n`\n\n|------------------------------------------|\n| android.view.Choreographer.FrameCallback |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nImplement this interface to receive a callback when a new display frame is\nbeing rendered. The callback is invoked on the [Looper](/reference/android/os/Looper) thread to\nwhich the [Choreographer](/reference/android/view/Choreographer) is attached.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[doFrame](/reference/android/view/Choreographer.FrameCallback#doFrame(long))`(long frameTimeNanos) ` Called when a new display frame is being rendered. |\n\nPublic methods\n--------------\n\n### doFrame\n\nAdded in [API level 16](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void doFrame (long frameTimeNanos)\n```\n\nCalled when a new display frame is being rendered.\n\n\nThis method provides the time in nanoseconds when the frame started being rendered.\nThe frame time provides a stable time base for synchronizing animations\nand drawing. It should be used instead of [SystemClock.uptimeMillis()](/reference/android/os/SystemClock#uptimeMillis())\nor [System.nanoTime()](/reference/java/lang/System#nanoTime()) for animations and drawing in the UI. Using the frame\ntime helps to reduce inter-frame jitter because the frame time is fixed at the time\nthe frame was scheduled to start, regardless of when the animations or drawing\ncallback actually runs. All callbacks that run as part of rendering a frame will\nobserve the same frame time so using the frame time also helps to synchronize effects\nthat are performed by different callbacks.\n\n\nPlease note that the framework already takes care to process animations and\ndrawing using the frame time as a stable time base. Most applications should\nnot need to use the frame time information directly.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `frameTimeNanos` | `long`: The time in nanoseconds when the frame started being rendered, in the [System.nanoTime()](/reference/java/lang/System#nanoTime()) timebase. Divide this value by `1000000` to convert it to the [SystemClock.uptimeMillis()](/reference/android/os/SystemClock#uptimeMillis()) time base. \u003cbr /\u003e |"]]