OnBackPressedDispatcherKt

public final class OnBackPressedDispatcherKt


Summary

Public methods

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

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

Public methods

OnBackPressedDispatcherKt.addCallback

@NonNull
public static final OnBackPressedCallback OnBackPressedDispatcherKt.addCallback(
    @NonNull OnBackPressedDispatcher receiver,
    @Nullable LifecycleOwner owner,
    boolean enabled,
    @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.