# androidx.activity

*** ** * ** ***

## Interfaces

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporterOwner` | A class that has a `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter` that allows you to have separate parts of the UI independently register when they have been fully loaded. |
| `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner` | A class that has an `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher` that allows you to register a `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedCallback` for handling the system back button. |

## Classes

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/BackEventCompat` | Compat around the `https://developer.android.com/reference/android/window/BackEvent.html` class |
| `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity` | Base class for activities that enables composition of higher level components. |
| `https://developer.android.com/reference/kotlin/androidx/activity/ComponentDialog` | Base class for dialogs that enables composition of higher level components. |
| `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter` | Manages when to call `https://developer.android.com/reference/android/app/Activity.html#reportFullyDrawn()`. |
| `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedCallback` | Class for handling `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher#onBackPressed()` callbacks without strongly coupling that implementation to a subclass of `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity`. |
| `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher` | Dispatcher that can be used to register `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedCallback` instances for handling the `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity#onBackPressed()` callback via composition. |
| `https://developer.android.com/reference/kotlin/androidx/activity/SystemBarStyle` | **This class is deprecated.** SystemBarStyle was used to configure enableEdgeToEdge. |

## Objects

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/ActivityFlags` | A collection of runtime feature flags used to guard behavior changes, migrations, or experimental paths within the `androidx.activity` package and its related integrations. |

## Annotations

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/ExperimentalActivityApi` | Marks declarations that are **experimental** in the Activity APIs. |

## Top-level functions summary

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner` | `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#NavigationEventDispatcherOwner(androidx.activity.OnBackPressedDispatcher)( onBackPressedDispatcher: https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher )` Creates a `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#NavigationEventDispatcherOwner(androidx.activity.OnBackPressedDispatcher)` directly backed by the provided `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher`. |
| `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner` | `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#NavigationEventDispatcherOwner(androidx.activity.OnBackPressedDispatcherOwner)( onBackPressedDispatcherOwner: https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner )` Creates a `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#NavigationEventDispatcherOwner(androidx.activity.OnBackPressedDispatcherOwner)` directly backed by the provided `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner`. |
| `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner` | `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#OnBackPressedDispatcherOwner(androidx.activity.OnBackPressedDispatcher,androidx.lifecycle.Lifecycle)( onBackPressedDispatcher: https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher, lifecycle: https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle )` Creates an `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#OnBackPressedDispatcherOwner(androidx.activity.OnBackPressedDispatcher,androidx.lifecycle.Lifecycle)` directly backed by the provided `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher` and `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle`. |

## Extension functions summary

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedCallback` | `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher.https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.OnBackPressedDispatcher).addCallback(androidx.lifecycle.LifecycleOwner,kotlin.Boolean,kotlin.Function1)( owner: https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner?, enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, onBackPressed: https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedCallback.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Creates and registers a new `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedCallback` that invokes `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.OnBackPressedDispatcher).addCallback(androidx.lifecycle.LifecycleOwner,kotlin.Boolean,kotlin.Function1)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.[enableEdgeToEdge](https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.ComponentActivity).enableEdgeToEdge(androidx.activity.SystemBarStyle,androidx.activity.SystemBarStyle))( statusBarStyle: https://developer.android.com/reference/kotlin/androidx/activity/SystemBarStyle, navigationBarStyle: https://developer.android.com/reference/kotlin/androidx/activity/SystemBarStyle )` **This function is deprecated.** Use {@link WindowCompat#enableEdgeToEdge(Window)} to enable edge-to-edge display. |
| `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporterOwner?` | `https://developer.android.com/reference/android/view/View.html.https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(android.view.View).findViewTreeFullyDrawnReporterOwner()()` Retrieve the `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporterOwner` associated with the given `https://developer.android.com/reference/android/view/View.html`. |
| `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner?` | `https://developer.android.com/reference/android/view/View.html.https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(android.view.View).findViewTreeOnBackPressedDispatcherOwner()()` Retrieve the `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner` associated with the given `https://developer.android.com/reference/android/view/View.html`. |
| `suspend inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter.https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.FullyDrawnReporter).reportWhenComplete(kotlin.coroutines.SuspendFunction0)(reporter: suspend () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Tells the `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter` to wait until `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.FullyDrawnReporter).reportWhenComplete(kotlin.coroutines.SuspendFunction0)` has completed before calling `https://developer.android.com/reference/android/app/Activity.html#reportFullyDrawn()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/android/view/View.html.https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(android.view.View).setViewTreeFullyDrawnReporterOwner(androidx.activity.FullyDrawnReporterOwner)( fullyDrawnReporterOwner: https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporterOwner )` Set the `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporterOwner` associated with the given `https://developer.android.com/reference/android/view/View.html`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/android/view/View.html.https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(android.view.View).setViewTreeOnBackPressedDispatcherOwner(androidx.activity.OnBackPressedDispatcherOwner)( onBackPressedDispatcherOwner: https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner )` Set the `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner` associated with the given `https://developer.android.com/reference/android/view/View.html`. |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi(value = 26) https://developer.android.com/reference/android/app/Activity.html.https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(android.app.Activity).trackPipAnimationHintView(android.view.View)(view: https://developer.android.com/reference/android/view/View.html)` Sets the `https://developer.android.com/reference/android/view/View.html` that will be used as reference to set the `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder.html#setSourceRectHint(android.graphics.Rect)`. |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-lazy/index.html<VM>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread <VM : https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel> https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.ComponentActivity).viewModels(kotlin.Function0,kotlin.Function0)( noinline extrasProducer: (() -> https://developer.android.com/reference/kotlin/androidx/lifecycle/viewmodel/CreationExtras)?, noinline factoryProducer: (() -> https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModelProvider.Factory)? )` Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-lazy/index.html` delegate to access the ComponentActivity's ViewModel, if `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.ComponentActivity).viewModels(kotlin.Function0,kotlin.Function0)` is specified then `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModelProvider.Factory` returned by it will be used to create `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel` first time. |
| `inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-lazy/index.html<T>` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread <T : https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel> https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity.https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.ComponentActivity).viewModels(kotlin.String,kotlin.Function0,kotlin.Function0)( key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, noinline extrasProducer: (() -> https://developer.android.com/reference/kotlin/androidx/lifecycle/viewmodel/CreationExtras)?, noinline factoryProducer: (() -> https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModelProvider.Factory)? )` Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-lazy/index.html` delegate for this `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity`'s `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel` identified by `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.ComponentActivity).viewModels(kotlin.String,kotlin.Function0,kotlin.Function0)`. |

## Top-level functions

### NavigationEventDispatcherOwner

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/NavigationEventDispatcherOwnerFactory.kt+function:NavigationEventDispatcherOwner) Added in [1.14.0-alpha03](https://developer.android.com/jetpack/androidx/releases/activity#1.14.0-alpha03)

```
fun NavigationEventDispatcherOwner(
    onBackPressedDispatcher: OnBackPressedDispatcher
): NavigationEventDispatcherOwner
```

Creates a `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#NavigationEventDispatcherOwner(androidx.activity.OnBackPressedDispatcher)` directly backed by the provided `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher`.

### NavigationEventDispatcherOwner

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/NavigationEventDispatcherOwnerFactory.kt+function:NavigationEventDispatcherOwner) Added in [1.14.0-alpha03](https://developer.android.com/jetpack/androidx/releases/activity#1.14.0-alpha03)

```
fun NavigationEventDispatcherOwner(
    onBackPressedDispatcherOwner: OnBackPressedDispatcherOwner
): NavigationEventDispatcherOwner
```

Creates a `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#NavigationEventDispatcherOwner(androidx.activity.OnBackPressedDispatcherOwner)` directly backed by the provided `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner`.

### OnBackPressedDispatcherOwner

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/OnBackPressedDispatcherOwnerFactory.kt+function:OnBackPressedDispatcherOwner) Added in [1.14.0-alpha03](https://developer.android.com/jetpack/androidx/releases/activity#1.14.0-alpha03)

```
fun OnBackPressedDispatcherOwner(
    onBackPressedDispatcher: OnBackPressedDispatcher,
    lifecycle: Lifecycle
): OnBackPressedDispatcherOwner
```

Creates an `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#OnBackPressedDispatcherOwner(androidx.activity.OnBackPressedDispatcher,androidx.lifecycle.Lifecycle)` directly backed by the provided `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcher` and `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle`.

## Extension functions

### OnBackPressedDispatcher.addCallback

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/OnBackPressedDispatcher.kt+function:addCallback) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

```
fun OnBackPressedDispatcher.addCallback(
    owner: LifecycleOwner? = null,
    enabled: Boolean = true,
    onBackPressed: OnBackPressedCallback.() -> Unit
): OnBackPressedCallback
```

Creates and registers a new `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedCallback` that invokes `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.OnBackPressedDispatcher).addCallback(androidx.lifecycle.LifecycleOwner,kotlin.Boolean,kotlin.Function1)`.

If a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner` is provided, the callback's enabled state automatically follows the lifecycle: it is enabled while the lifecycle is at least `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#STARTED` and disabled otherwise. The callback stays registered until the `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner` is destroyed.

A default `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.OnBackPressedDispatcher).addCallback(androidx.lifecycle.LifecycleOwner,kotlin.Boolean,kotlin.Function1)` state can be supplied.

## Legacy Behavior

To restore the legacy add/remove behavior, set `https://developer.android.com/reference/kotlin/androidx/activity/ActivityFlags#isOnBackPressedLifecycleOrderMaintained()` to `false`. In legacy mode, the handler is added on `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.Event#ON_START` and removed on `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.Event#ON_STOP`, which may change dispatch ordering across lifecycle transitions.

### ComponentActivity.enableEdgeToEdge

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/EdgeToEdge.kt+function:enableEdgeToEdge) Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/activity#1.8.0) Deprecated in [1.14.0-alpha03](https://developer.android.com/jetpack/androidx/releases/activity#1.14.0-alpha03)

```
fun ComponentActivity.[enableEdgeToEdge](https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.ComponentActivity).enableEdgeToEdge(androidx.activity.SystemBarStyle,androidx.activity.SystemBarStyle))(
    statusBarStyle: SystemBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT),
    navigationBarStyle: SystemBarStyle = SystemBarStyle.auto(DefaultLightScrim, DefaultDarkScrim)
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> Use {@link WindowCompat#enableEdgeToEdge(Window)} to enable edge-to-edge display. To adjust the light/dark appearance of system bar icons, use {@link WindowInsetsControllerCompat#setAppearanceLightStatusBars(boolean)} or {@link WindowInsetsControllerCompat#setAppearanceLightNavigationBars(boolean)}. To add scrim or background protection, use {@link ProtectionLayout} or handle insets directly in your view hierarchy, use this instead:
>
> ```kotlin
> WindowCompat.enableEdgeToEdge(window)
> ```

Enables the edge-to-edge display for this `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity`.

To set it up with the default style, call this method in your Activity's onCreate method:

```kotlin
    override fun onCreate(savedInstanceState: Bundle?) {
        enableEdgeToEdge()
        super.onCreate(savedInstanceState)
        ...
    }
```

The default style configures the system bars with a transparent background when contrast can be enforced by the system (API 29 or above). On older platforms (which only have 3-button/2-button navigation modes), an equivalent scrim is applied to ensure contrast with the system bars.

See `https://developer.android.com/reference/kotlin/androidx/activity/SystemBarStyle` for more customization options.

| Parameters |
|---|---|
| `statusBarStyle: https://developer.android.com/reference/kotlin/androidx/activity/SystemBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT)` | The `https://developer.android.com/reference/kotlin/androidx/activity/SystemBarStyle` for the status bar. |
| `navigationBarStyle: https://developer.android.com/reference/kotlin/androidx/activity/SystemBarStyle = SystemBarStyle.auto(DefaultLightScrim, DefaultDarkScrim)` | The `https://developer.android.com/reference/kotlin/androidx/activity/SystemBarStyle` for the navigation bar. |

### View.findViewTreeFullyDrawnReporterOwner

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/ViewTreeFullyLoadedReporterOwner.kt+function:findViewTreeFullyDrawnReporterOwner) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

```
fun View.findViewTreeFullyDrawnReporterOwner(): FullyDrawnReporterOwner?
```

Retrieve the `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporterOwner` associated with the given `https://developer.android.com/reference/android/view/View.html`. This may be used to indicate that a part of the UI is drawn and ready for first user interaction.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporterOwner?` | The `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporterOwner` associated with this view and/or some subset of its ancestors |

### View.findViewTreeOnBackPressedDispatcherOwner

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/ViewTreeOnBackPressedDispatcherOwner.kt+function:findViewTreeOnBackPressedDispatcherOwner) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/activity#1.5.0)

```
fun View.findViewTreeOnBackPressedDispatcherOwner(): OnBackPressedDispatcherOwner?
```

Retrieve the `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner` associated with the given `https://developer.android.com/reference/android/view/View.html`. This may be used to add a callback for the system back button.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner?` | The `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner` associated with this view and/or some subset of its ancestors |

### FullyDrawnReporter.reportWhenComplete

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/FullyDrawnReporter.kt+function:reportWhenComplete) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

```
suspend inline fun FullyDrawnReporter.reportWhenComplete(reporter: suspend () -> Unit): Unit
```

Tells the `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter` to wait until `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.FullyDrawnReporter).reportWhenComplete(kotlin.coroutines.SuspendFunction0)` has completed before calling `https://developer.android.com/reference/android/app/Activity.html#reportFullyDrawn()`.

### View.setViewTreeFullyDrawnReporterOwner

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/ViewTreeFullyLoadedReporterOwner.kt+function:setViewTreeFullyDrawnReporterOwner) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

```
fun View.setViewTreeFullyDrawnReporterOwner(
    fullyDrawnReporterOwner: FullyDrawnReporterOwner
): Unit
```

Set the `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporterOwner` associated with the given `https://developer.android.com/reference/android/view/View.html`. Calls to `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(android.view.View).findViewTreeFullyDrawnReporterOwner()` from this `https://developer.android.com/reference/android/view/View.html` or descendants will return `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(android.view.View).setViewTreeFullyDrawnReporterOwner(androidx.activity.FullyDrawnReporterOwner)`.

This should only be called by constructs such as activities that manage a view tree and handle the dispatch of `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity#reportFullyDrawn()`.

| Parameters |
|---|---|
| `fullyDrawnReporterOwner: https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporterOwner` | `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporterOwner` associated with the `https://developer.android.com/reference/android/view/View.html` |

### View.setViewTreeOnBackPressedDispatcherOwner

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/ViewTreeOnBackPressedDispatcherOwner.kt+function:setViewTreeOnBackPressedDispatcherOwner) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/activity#1.5.0)

```
fun View.setViewTreeOnBackPressedDispatcherOwner(
    onBackPressedDispatcherOwner: OnBackPressedDispatcherOwner
): Unit
```

Set the `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner` associated with the given `https://developer.android.com/reference/android/view/View.html`. Calls to `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(android.view.View).findViewTreeOnBackPressedDispatcherOwner()` from this view or descendants will return `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(android.view.View).setViewTreeOnBackPressedDispatcherOwner(androidx.activity.OnBackPressedDispatcherOwner)`.

This should only be called by constructs such as activities or dialogs that manage a view tree and handle the dispatch of the system back button. Callers should only set a `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner` that will be *stable.*

| Parameters |
|---|---|
| `onBackPressedDispatcherOwner: https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner` | `https://developer.android.com/reference/kotlin/androidx/activity/OnBackPressedDispatcherOwner` associated with the `https://developer.android.com/reference/android/view/View.html` |

### Activity.trackPipAnimationHintView

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/PipHintTracker.kt+function:trackPipAnimationHintView) Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/activity#1.9.0)

```
@RequiresApi(value = 26)
suspend fun Activity.trackPipAnimationHintView(view: View): Unit
```

Sets the `https://developer.android.com/reference/android/view/View.html` that will be used as reference to set the `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder.html#setSourceRectHint(android.graphics.Rect)`.

Anytime the view position changes, `https://developer.android.com/reference/android/app/Activity.html#setPictureInPictureParams(android.app.PictureInPictureParams)` will be called with the updated view's position in window coordinates as the `https://developer.android.com/reference/android/app/PictureInPictureParams.Builder.html#setSourceRectHint(android.graphics.Rect)`.

| Parameters |
|---|---|
| `view: https://developer.android.com/reference/android/view/View.html` | the view to use as the reference for the source rect hint |

### ComponentActivity.viewModels

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

```
@MainThread
inline fun <VM : ViewModel> ComponentActivity.viewModels(
    noinline extrasProducer: (() -> CreationExtras)? = null,
    noinline factoryProducer: (() -> ViewModelProvider.Factory)? = null
): Lazy<VM>
```

Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-lazy/index.html` delegate to access the ComponentActivity's ViewModel, if `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.ComponentActivity).viewModels(kotlin.Function0,kotlin.Function0)` is specified then `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModelProvider.Factory` returned by it will be used to create `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel` first time.

```kotlin
class MyComponentActivity : ComponentActivity() {
    val viewmodel: MyViewModel by viewModels()
}
```

This property can be accessed only after the Activity is attached to the Application, and access prior to that will result in IllegalArgumentException.

### ComponentActivity.viewModels

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

```
@MainThread
inline fun <T : ViewModel> ComponentActivity.viewModels(
    key: String,
    noinline extrasProducer: (() -> CreationExtras)? = null,
    noinline factoryProducer: (() -> ViewModelProvider.Factory)? = null
): Lazy<T>
```

Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-lazy/index.html` delegate for this `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity`'s `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel` identified by `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.ComponentActivity).viewModels(kotlin.String,kotlin.Function0,kotlin.Function0)`.

Delegates with the same `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.ComponentActivity).viewModels(kotlin.String,kotlin.Function0,kotlin.Function0)` and `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel` type share the same instance. Different keys allow multiple instances of the same `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel` type in this activity.

```kotlin
class MyComponentActivity : ComponentActivity() {
    val primaryViewModel: MyViewModel by viewModels(key = "primary")
    val secondaryViewModel: MyViewModel by viewModels(key = "secondary")
}
```

This property can be accessed only after the Activity is attached to the Application. Access before that results in an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html`.

| Parameters |
|---|---|
| `key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | identifier used to store and retrieve the `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel` |
| `noinline extrasProducer: (() -> https://developer.android.com/reference/kotlin/androidx/lifecycle/viewmodel/CreationExtras)? = null` | producer of the `https://developer.android.com/reference/kotlin/androidx/lifecycle/viewmodel/CreationExtras` used to create the `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel` |
| `noinline factoryProducer: (() -> https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModelProvider.Factory)? = null` | producer of the `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModelProvider.Factory` used to create the `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel` |