# ContextAwareKt

Added in 1.7.0

*** ** * ** ***


```
public final class ContextAwareKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull R` | `<R extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/activity/contextaware/ContextAwareKt#(androidx.activity.contextaware.ContextAware).withContextAvailable(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/activity/contextaware/ContextAware receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/content/Context.html, @https://developer.android.com/reference/androidx/annotation/NonNull R> onContextAvailable )` Run `https://developer.android.com/reference/androidx/activity/contextaware/package-summary#(androidx.activity.contextaware.ContextAware).withContextAvailable(kotlin.Function1)` when the `https://developer.android.com/reference/android/content/Context.html` becomes available and resume with the result. |

## Public methods

### withContextAvailable

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/contextaware/ContextAware.kt+function:withContextAvailable)

```
public static final @NonNull R <R extends Object> withContextAvailable(
    @NonNull ContextAware receiver,
    @NonNull Function1<@NonNull Context, @NonNull R> onContextAvailable
)
```

Run `https://developer.android.com/reference/androidx/activity/contextaware/package-summary#(androidx.activity.contextaware.ContextAware).withContextAvailable(kotlin.Function1)` when the `https://developer.android.com/reference/android/content/Context.html` becomes available and resume with the result.

If the `https://developer.android.com/reference/android/content/Context.html` is already available, `https://developer.android.com/reference/androidx/activity/contextaware/package-summary#(androidx.activity.contextaware.ContextAware).withContextAvailable(kotlin.Function1)` will be synchronously called on the current coroutine context. Otherwise, `https://developer.android.com/reference/androidx/activity/contextaware/package-summary#(androidx.activity.contextaware.ContextAware).withContextAvailable(kotlin.Function1)` will be called on the UI thread immediately when the Context becomes available.