AndroidUiContext

A CoroutineContext.Element for binding an Android activity Context to a coroutine.

In Compose, use org.multipaz.compose.rememberUiBoundCoroutineScope to automatically include an AndroidUiContext in the coroutine scope. When not using Compose, pass AndroidUiContext(activity) to launch or withContext:

withContext(AndroidUiContext(activity)) {
...
}

Parameters

context

the Context being held; must be an android.app.Activity or wrap one via android.content.ContextWrapper.

See also

Constructors

Link copied to clipboard
constructor(context: Context)

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard
open override val key: CoroutineContext.Key<*>

Functions

Link copied to clipboard
open override fun <R> fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R
Link copied to clipboard
open operator override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E?
Link copied to clipboard
open override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext
Link copied to clipboard
open operator fun plus(context: CoroutineContext): CoroutineContext