Stay organized with collections
Save and categorize content based on your preferences.
OnFrameMetricsAvailableListener
interface OnFrameMetricsAvailableListener
Callback for clients that want frame timing information for each frame rendered by the Window.
Summary
Public methods |
abstract Unit |
Called when information is available for the previously rendered frame.
|
Public methods
onFrameMetricsAvailable
abstract fun onFrameMetricsAvailable(
window: Window!,
frameMetrics: FrameMetrics!,
dropCountSinceLastInvocation: Int
): Unit
Called when information is available for the previously rendered frame. Reports can be dropped if this callback takes too long to execute, as the report producer cannot wait for the consumer to complete. It is highly recommended that clients copy the passed in FrameMetrics via FrameMetrics.FrameMetrics(FrameMetrics)
within this method and defer additional computation or storage to another thread to avoid unnecessarily dropping reports.
Parameters |
window |
Window!: The Window on which the frame was displayed. |
frameMetrics |
FrameMetrics!: the available metrics. This object is reused on every call and thus this reference is not valid outside the scope of this method. |
dropCountSinceLastInvocation |
Int: the number of reports dropped since the last time this callback was invoked. |
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,["# Window.OnFrameMetricsAvailableListener\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnFrameMetricsAvailableListener\n===============================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/Window.OnFrameMetricsAvailableListener \"View this page in Java\") \n\n```\ninterface OnFrameMetricsAvailableListener\n```\n\n|----------------------------------------------------------|\n| [android.view.Window.OnFrameMetricsAvailableListener](#) |\n\nCallback for clients that want frame timing information for each frame rendered by the Window.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onFrameMetricsAvailable](#onFrameMetricsAvailable(android.view.Window,%20android.view.FrameMetrics,%20kotlin.Int))`(`window:` `[Window](/reference/kotlin/android/view/Window)!`, `frameMetrics:` `[FrameMetrics](/reference/kotlin/android/view/FrameMetrics)!`, `dropCountSinceLastInvocation:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Called when information is available for the previously rendered frame. |\n\nPublic methods\n--------------\n\n### onFrameMetricsAvailable\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onFrameMetricsAvailable(\n window: Window!, \n frameMetrics: FrameMetrics!, \n dropCountSinceLastInvocation: Int\n): Unit\n```\n\nCalled when information is available for the previously rendered frame. Reports can be dropped if this callback takes too long to execute, as the report producer cannot wait for the consumer to complete. It is highly recommended that clients copy the passed in FrameMetrics via [FrameMetrics.FrameMetrics(FrameMetrics)](/reference/kotlin/android/view/FrameMetrics#FrameMetrics(android.view.FrameMetrics)) within this method and defer additional computation or storage to another thread to avoid unnecessarily dropping reports.\n\n| Parameters ||\n|--------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `window` | [Window](/reference/kotlin/android/view/Window)!: The [Window](/reference/kotlin/android/view/Window) on which the frame was displayed. |\n| `frameMetrics` | [FrameMetrics](/reference/kotlin/android/view/FrameMetrics)!: the available metrics. This object is reused on every call and thus **this reference is not valid outside the scope of this method**. |\n| `dropCountSinceLastInvocation` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the number of reports dropped since the last time this callback was invoked. |"]]