stateLimit

var stateLimit: Lifecycle.State? = null

Limits the states of this lifecycle owner to the given value.

May only be set to null, State.CREATED and State.STARTED.

If set to:

  • State.CREATED or State.STARTED and the current state is higher than the given value, the current state is decreased to the given value.

  • State.CREATED or State.STARTED and the current state is lower than the given value and the parentLifecycleOwner state, the current state is increased to the given value.

  • State.CREATED or State.STARTED and the current state is lower than the given value and higher than the parentLifecycleOwner state, the current state is increased to the parentLifecycleOwner state.

  • null, the current state is set to the parentLifecycleOwner's state.

If set to State.CREATED or State.STARTED's state changes are ignored if the parentLifecycleOwner's state is higher than the set value.

The initial value is null.