Lifecycle.Event



Represents a transition event triggered by a change in the LifecycleOwner's state.

Together with States, these events form a directed graph defining the valid lifecycle flow of a component:

           +-------------+
| INITIALIZED |
+-------------+
|
| ON_CREATE
v
+---------+
| CREATED | ----------+
+---------+ |
| ^ |
ON_START | | ON_STOP |
v | | ON_DESTROY
+---------+ |
| STARTED | |
+---------+ |
| ^ |
ON_RESUME | | ON_PAUSE |
v | v
+---------+ +-----------+
| RESUMED | | DESTROYED |
+---------+ +-----------+
See also
Lifecycle.State

for the states resulting from these transition events.

Summary

Enum Values

ON_ANY

A wildcard event constant that matches all Events.

ON_CREATE

Dispatched when the LifecycleOwner enters the created state.

ON_DESTROY

Dispatched when the LifecycleOwner is about to be destroyed.

ON_PAUSE

Dispatched when the LifecycleOwner is about to leave the resumed state.

ON_RESUME

Dispatched when the LifecycleOwner enters the resumed state.

ON_START

Dispatched when the LifecycleOwner enters the started state.

ON_STOP

Dispatched when the LifecycleOwner is about to leave the started state.

Public companion functions

Lifecycle.Event?

Returns the Event that transitions down from the specified state to a lower state, or null if no transition exists.

Cmn
Lifecycle.Event?

Returns the Event that transitions down into the specified target state, or null if no transition exists.

Cmn
Lifecycle.Event?

Returns the Event that transitions up from the specified state to a higher state, or null if no transition exists.

Cmn
Lifecycle.Event?

Returns the Event that transitions up into the specified target state, or null if no transition exists.

Cmn

Public functions

Lifecycle.Event
valueOf(value: String)

Returns the enum constant of this type with the specified name.

Cmn
Array<Lifecycle.Event>

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

Cmn

Public properties

EnumEntries<Lifecycle.Event>

Returns an immutable kotlin.enums.EnumEntries list containing the constants of this enum type, in the order they're declared.

Cmn
Lifecycle.State

Returns the new State of a Lifecycle that just reported this Event.

Cmn

Enum Values

ON_ANY

val Lifecycle.Event.ON_ANYLifecycle.Event

A wildcard event constant that matches all Events.

ON_CREATE

val Lifecycle.Event.ON_CREATELifecycle.Event

Dispatched when the LifecycleOwner enters the created state.

Called after the LifecycleOwner's onCreate returns. Transitions the lifecycle to State.CREATED.

ON_DESTROY

val Lifecycle.Event.ON_DESTROYLifecycle.Event

Dispatched when the LifecycleOwner is about to be destroyed.

Called before the LifecycleOwner's onDestroy is called. Transitions the lifecycle to State.DESTROYED.

ON_PAUSE

val Lifecycle.Event.ON_PAUSELifecycle.Event

Dispatched when the LifecycleOwner is about to leave the resumed state.

Called before the LifecycleOwner's onPause is called. Transitions the lifecycle to State.STARTED.

ON_RESUME

val Lifecycle.Event.ON_RESUMELifecycle.Event

Dispatched when the LifecycleOwner enters the resumed state.

Called after the LifecycleOwner's onResume returns. Transitions the lifecycle to State.RESUMED.

ON_START

val Lifecycle.Event.ON_STARTLifecycle.Event

Dispatched when the LifecycleOwner enters the started state.

Called after the LifecycleOwner's onStart returns. Transitions the lifecycle to State.STARTED.

ON_STOP

val Lifecycle.Event.ON_STOPLifecycle.Event

Dispatched when the LifecycleOwner is about to leave the started state.

Called before the LifecycleOwner's onStop is called. Transitions the lifecycle to State.CREATED.

Public companion functions

downFrom

fun downFrom(state: Lifecycle.State): Lifecycle.Event?

Returns the Event that transitions down from the specified state to a lower state, or null if no transition exists.

Given state Returned Event
State.DESTROYED null
State.INITIALIZED null
State.CREATED Event.ON_DESTROY
State.STARTED Event.ON_STOP
State.RESUMED Event.ON_PAUSE

downTo

fun downTo(state: Lifecycle.State): Lifecycle.Event?

Returns the Event that transitions down into the specified target state, or null if no transition exists.

Target state Returned Event
State.DESTROYED Event.ON_DESTROY
State.INITIALIZED null
State.CREATED Event.ON_STOP
State.STARTED Event.ON_PAUSE
State.RESUMED null

upFrom

fun upFrom(state: Lifecycle.State): Lifecycle.Event?

Returns the Event that transitions up from the specified state to a higher state, or null if no transition exists.

Given state Returned Event
State.DESTROYED null
State.INITIALIZED Event.ON_CREATE
State.CREATED Event.ON_START
State.STARTED Event.ON_RESUME
State.RESUMED null

upTo

fun upTo(state: Lifecycle.State): Lifecycle.Event?

Returns the Event that transitions up into the specified target state, or null if no transition exists.

Target state Returned Event
State.DESTROYED null
State.INITIALIZED null
State.CREATED Event.ON_CREATE
State.STARTED Event.ON_START
State.RESUMED Event.ON_RESUME

Public functions

valueOf

fun valueOf(value: String): Lifecycle.Event

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
kotlin.IllegalArgumentException

if this enum type has no constant with the specified name

values

fun values(): Array<Lifecycle.Event>

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

val entriesEnumEntries<Lifecycle.Event>

Returns an immutable kotlin.enums.EnumEntries list containing the constants of this enum type, in the order they're declared.