---
title: "AndroidUiDispatcher"
description: "A [CoroutineDispatcher] that will perform dispatch during a [handler] callback or
[choreographer]'s animation frame stage, whichever comes first. Use [Main] to obtain a dispatcher
for the process's main thread (i.e. the activity thread) or [CurrentThread] to obtain a
dispatcher for the current thread."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-android'>Android</div>


```kotlin
class AndroidUiDispatcher
private constructor(val choreographer: Choreographer, private val handler: android.os.Handler) :
    CoroutineDispatcher()
```


A `CoroutineDispatcher` that will perform dispatch during a `handler` callback or
`choreographer`'s animation frame stage, whichever comes first. Use `Main` to obtain a dispatcher
for the process's main thread (i.e. the activity thread) or `CurrentThread` to obtain a
dispatcher for the current thread.


## Properties

<div class='sourceset sourceset-android'>Android</div>


```kotlin
val frameClock: MonotonicFrameClock
```


A `MonotonicFrameClock` associated with this `AndroidUiDispatcher`'s `choreographer` that may
be used to await `Choreographer` frame dispatch.



## Companion Object

#### Properties

<div class='sourceset sourceset-android'>Android</div>


```kotlin
val Main: CoroutineContext
```


The `CoroutineContext` containing the `AndroidUiDispatcher` and its `frameClock` for the
process's main thread.



<div class='sourceset sourceset-android'>Android</div>


```kotlin
val CurrentThread: CoroutineContext
```


The canonical `CoroutineContext` containing the `AndroidUiDispatcher` and its
`frameClock` for the calling thread. Returns `Main` if accessed from the process's main
thread.

Throws `IllegalStateException` if the calling thread does not have both a `Choreographer`
and an active `Looper`.





