# Lifecycle.State

Artifact: [androidx.lifecycle:lifecycle-common](https://developer.android.com/jetpack/androidx/releases/lifecycle) [View Source](https://cs.android.com/search?q=file:androidx/lifecycle/Lifecycle.kt+class:androidx.lifecycle.Lifecycle.State) Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.0.0)

*** ** * ** ***

Common/AllAndroid/JVM
- Cmn

  ```
  enum Lifecycle.State : Enum<Lifecycle.State>
  ```

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [kotlin.Enum](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-enum/index.html)\<[Lifecycle.State](https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State)\> ||
|   | ↳ | [androidx.lifecycle.Lifecycle.State](https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State) |

*** ** * ** ***

Represents the current lifecycle state of a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`.

You can visualize these states as nodes in a graph where `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.Event`s represent the directed edges guiding transitions between them:

```kotlin
           +---+
           | INITIALIZED |
           +---+
                  |
                  | ON_CREATE
                  v
             +---+
             | CREATED | ---+
             +---+           |
              |       ^            |
     ON_START |       | ON_STOP    |
              v       |            | ON_DESTROY
             +---+           |
             | STARTED |           |
             +---+           |
              |       ^            |
    ON_RESUME |       | ON_PAUSE   |
              v       |            v
             +---+     +---+
             | RESUMED |     | DESTROYED |
             +---+     +---+
```

Transitions between these states occur strictly sequentially. When moving between non-adjacent states, the registry dispatches all intermediate `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.Event`s. For example, transitioning from `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#RESUMED` to `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#DESTROYED` will sequentially dispatch `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.Event#ON_PAUSE`, `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.Event#ON_STOP`, and `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.Event#ON_DESTROY`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.Event` | for the transition events between these states. |

## Summary

| ### Enum Values |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#CREATED` | Created state for a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`. |
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#DESTROYED` | Destroyed state for a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`. |
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#INITIALIZED` | Initialized state for a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`. |
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#RESUMED` | Resumed state for a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`. |
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#STARTED` | Started state for a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`. |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#isAtLeast(androidx.lifecycle.Lifecycle.State)(state: https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State)` Returns true if this state is greater than or equal to the given `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#isAtLeast(androidx.lifecycle.Lifecycle.State)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State` | `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#valueOf(kotlin.String)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Returns the enum constant of this type with the specified name. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State>` | `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#values()()` Returns an array containing the constants of this enum type, in the order they're declared. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html<https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State>` | `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#entries()` Returns an immutable `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html` list containing the constants of this enum type, in the order they're declared. | Cmn |

## Enum Values

### CREATED

```
val Lifecycle.State.CREATED: Lifecycle.State
```

Created state for a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`.

**This is a cyclic state.** The lifecycle can transition back and forth between `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#CREATED`, `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#STARTED`, and `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#RESUMED` states.

For instance, for an Android Activity, this state is reached after the activity's `onCreate` returns, or right before `onStop` is called.

### DESTROYED

```
val Lifecycle.State.DESTROYED: Lifecycle.State
```

Destroyed state for a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`.

**This is the terminal state.** Once reached, this `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle` will not dispatch any more events, and it cannot transition to any other state.

For instance, for an Android Activity, this state is reached right before the activity's `onDestroy` is called.

### INITIALIZED

```
val Lifecycle.State.INITIALIZED: Lifecycle.State
```

Initialized state for a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`.

**This is the initial state.** Once the lifecycle transitions out of this state, it cannot transition back to it.

For instance, for an Android Activity, this is the state when it is constructed but has not received `onCreate` yet.

### RESUMED

```
val Lifecycle.State.RESUMED: Lifecycle.State
```

Resumed state for a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`.

**This is a cyclic state.** The lifecycle can transition back and forth between `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#CREATED`, `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#STARTED`, and `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#RESUMED` states.

For instance, for an Android Activity, this state is reached after the activity's `onResume` returns.

### STARTED

```
val Lifecycle.State.STARTED: Lifecycle.State
```

Started state for a `https://developer.android.com/reference/kotlin/androidx/lifecycle/LifecycleOwner`.

**This is a cyclic state.** The lifecycle can transition back and forth between `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#CREATED`, `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#STARTED`, and `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#RESUMED` states.

For instance, for an Android Activity, this state is reached after the activity's `onStart` returns, or right before `onPause` is called.

## Public functions

### isAtLeast

Cmn Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.0.0)

```
fun isAtLeast(state: Lifecycle.State): Boolean
```

Returns true if this state is greater than or equal to the given `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#isAtLeast(androidx.lifecycle.Lifecycle.State)`.

States are ordered as `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#DESTROYED`\<`https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#INITIALIZED`\<`https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#CREATED`\<`https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#STARTED`\<`https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle.State#RESUMED`.

### valueOf

Cmn Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.0.0)

```
fun valueOf(value: String): Lifecycle.State
```

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if this enum type has no constant with the specified name |

### values

Cmn Added in [2.0.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.0.0)

```
fun values(): Array<Lifecycle.State>
```

Returns an array containing the constants of this enum type, in the order they're declared.

This method may be used to iterate over the constants.

The function returns a new instance of the array on every call. The array could be mutated, so working with it may also require defensive copying. Consider using `entries` property as a more efficient alternative returning an immutable list of enum entries.

## Public properties

### entries

Cmn

```
val entries: EnumEntries<Lifecycle.State>
```

Returns an immutable `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.enums/-enum-entries/index.html` list containing the constants of this enum type, in the order they're declared.