The Android Developer Challenge is back! Submit your idea before December 2.

LifecycleOwner

interface LifecycleOwner
androidx.lifecycle.LifecycleOwner

A class that has an Android lifecycle. These events can be used by custom components to handle lifecycle changes without implementing any code inside the Activity or the Fragment.

Summary

Public methods

abstract Lifecycle

Returns the Lifecycle of the provider.

Extension functions

From androidx.lifecycle
suspend T
LifecycleOwner.whenCreated(block: suspend CoroutineScope.() -> T)

Runs the given block when the LifecycleOwner's Lifecycle is at least in Lifecycle.State.CREATED state.

suspend T
LifecycleOwner.whenResumed(block: suspend CoroutineScope.() -> T)

Runs the given block when the LifecycleOwner's Lifecycle is at least in Lifecycle.State.RESUMED state.

suspend T
LifecycleOwner.whenStarted(block: suspend CoroutineScope.() -> T)

Runs the given block when the LifecycleOwner's Lifecycle is at least in Lifecycle.State.STARTED state.

Extension properties

From androidx.lifecycle
LifecycleCoroutineScope

CoroutineScope tied to this LifecycleOwner's Lifecycle.

Public methods

getLifecycle

@NonNull abstract fun getLifecycle(): Lifecycle

Returns the Lifecycle of the provider.

Return
Lifecycle: The lifecycle of the provider.