LifecycleEventObserver


public fun interface LifecycleEventObserver extends LifecycleObserver


Class that can receive any lifecycle change and dispatch it to the receiver.

If a class implements both this interface and androidx.lifecycle.DefaultLifecycleObserver, then methods of DefaultLifecycleObserver will be called first, and then followed by the call of LifecycleEventObserver.onStateChanged

If a class implements this interface and in the same time uses OnLifecycleEvent, then annotations will be ignored.

Summary

Public methods

abstract void
onStateChanged(
    @NonNull LifecycleOwner source,
    @NonNull Lifecycle.Event event
)

Called when a state transition event happens.

Public methods

onStateChanged

Added in 2.1.0
abstract void onStateChanged(
    @NonNull LifecycleOwner source,
    @NonNull Lifecycle.Event event
)

Called when a state transition event happens.

Parameters
@NonNull LifecycleOwner source

The source of the event

@NonNull Lifecycle.Event event

The event