# ActivityFlags

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

*** ** * ** ***


```
@ExperimentalActivityApi
public static class ActivityFlags
```

<br />

*** ** * ** ***

A collection of runtime feature flags used to guard behavior changes, migrations, or experimental paths within the `androidx.activity` package and its related integrations.

These flags are **mutable** to support temporary toggling, staged rollouts, and regression isolation. They are **not API-stable** and may be changed or removed at any time.

All flags default to values that reflect the intended behavior for current stable releases. If you encounter a regression that can be mitigated by toggling a flag, please file a bug referencing the flag name.

**Usage:**

Flags should be set as early as possible, ideally during application startup, before any Activity or Compose integration code runs. Changing a flag at runtime may lead to inconsistent behavior.

```
class MyApplication : Application() {
    override fun onCreate() {
        ActivityFlags.useEnableDisableForOnBackPressedLifecycle = true
        super.onCreate()
    }
}
```

## Summary

| ### Public fields |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/activity/ActivityFlags` | `https://developer.android.com/reference/androidx/activity/ActivityFlags#INSTANCE()` |
| `static final boolean` | `https://developer.android.com/reference/androidx/activity/ActivityFlags#isOnBackPressedLifecycleOrderMaintained()` Toggles how `https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher#addCallback(androidx.activity.OnBackPressedCallback)` responds to lifecycle changes. |
| `static final boolean` | `https://developer.android.com/reference/androidx/activity/ActivityFlags#isUntrustedActivityDefaultViewModelArgsEnabled()` **This field is deprecated.** To pass default arguments to the exported Activity override \[defaultViewModelArgs\]. |

## Public fields

### INSTANCE

Added in [1.12.0](https://developer.android.com/jetpack/androidx/releases/activity#1.12.0)

```
public static @NonNull ActivityFlags INSTANCE
```

### isOnBackPressedLifecycleOrderMaintained

Added in [1.12.0](https://developer.android.com/jetpack/androidx/releases/activity#1.12.0)

```
public static final boolean isOnBackPressedLifecycleOrderMaintained
```

Toggles how `https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher#addCallback(androidx.activity.OnBackPressedCallback)` responds to lifecycle changes.

When `true` (default), callbacks are **enabled and disabled** in place without being re-added. This preserves handler ordering across lifecycle transitions and improves interoperability with APIs such as `NavigationEventDispatcher` and `BackHandler`.

When `false`, `https://developer.android.com/reference/androidx/activity/OnBackPressedDispatcher` uses the legacy behavior of **adding and removing** callbacks as the associated `https://developer.android.com/reference/androidx/lifecycle/LifecycleOwner` moves between `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_START` and `https://developer.android.com/reference/androidx/lifecycle/Lifecycle.Event#ON_STOP`. This can reorder the callback stack when lifecycle transitions occur, which may affect the relative priority of registered handlers.

This flag is intended for testing and migration. It may be removed once the legacy behavior is fully retired.

### isUntrustedActivityDefaultViewModelArgsEnabled

Added in [1.14.0-alpha03](https://developer.android.com/jetpack/androidx/releases/activity#1.14.0-alpha03) Deprecated in [1.14.0-alpha03](https://developer.android.com/jetpack/androidx/releases/activity#1.14.0-alpha03)

```
public static final boolean isUntrustedActivityDefaultViewModelArgsEnabled
```

> [!CAUTION]
> **This field is deprecated.**   
> To pass default arguments to the exported Activity override \[defaultViewModelArgs\].

Control whether `https://developer.android.com/reference/androidx/activity/ComponentActivity` allows untrusted Intent extras, such as those from exported activities, to populate ViewModel saved state.

This should be set before ViewModels are created or `https://developer.android.com/reference/androidx/activity/ComponentActivity#defaultViewModelArgs()` is accessed (e.g., in your `https://developer.android.com/reference/android/app/Application.html` class or prior to `super.onCreate()` in your activity).