OnBackPressedDispatcherKt

Added in 1.0.0

public final class OnBackPressedDispatcherKt


Summary

Public methods

static final @NonNull OnBackPressedCallback
addCallback(
    @NonNull OnBackPressedDispatcher receiver,
    LifecycleOwner owner,
    boolean enabled,
    @ExtensionFunctionType @NonNull Function1<@NonNull OnBackPressedCallbackUnit> onBackPressed
)

Create and add a new OnBackPressedCallback that calls onBackPressed in OnBackPressedCallback.handleOnBackPressed.

Public methods

addCallback

public static final @NonNull OnBackPressedCallback addCallback(
    @NonNull OnBackPressedDispatcher receiver,
    LifecycleOwner owner,
    boolean enabled,
    @ExtensionFunctionType @NonNull Function1<@NonNull OnBackPressedCallbackUnit> onBackPressed
)

Create and add a new OnBackPressedCallback that calls onBackPressed in OnBackPressedCallback.handleOnBackPressed.

If an owner is specified, the callback will only be added when the Lifecycle is androidx.lifecycle.Lifecycle.State.STARTED.

A default enabled state can be supplied.