Stay organized with collections Save and categorize content based on your preferences.

ViewTreeOnBackPressedDispatcherOwner

public final class ViewTreeOnBackPressedDispatcherOwner


Summary

Public methods

static final OnBackPressedDispatcherOwner

Retrieve the OnBackPressedDispatcherOwner associated with the given View.

static final void
ViewTreeOnBackPressedDispatcherOwner.set(
    @NonNull View receiver,
    @NonNull OnBackPressedDispatcherOwner onBackPressedDispatcherOwner
)

Set the OnBackPressedDispatcherOwner associated with the given View.

Public methods

ViewTreeOnBackPressedDispatcherOwner.get

public static final OnBackPressedDispatcherOwner ViewTreeOnBackPressedDispatcherOwner.get(@NonNull View receiver)

Retrieve the OnBackPressedDispatcherOwner associated with the given View. This may be used to add a callback for the system back button.

Returns
OnBackPressedDispatcherOwner

The OnBackPressedDispatcherOwner associated with this view and/or some subset of its ancestors

ViewTreeOnBackPressedDispatcherOwner.set

public static final void ViewTreeOnBackPressedDispatcherOwner.set(
    @NonNull View receiver,
    @NonNull OnBackPressedDispatcherOwner onBackPressedDispatcherOwner
)

Set the OnBackPressedDispatcherOwner associated with the given View. Calls to findViewTreeOnBackPressedDispatcherOwner from this view or descendants will return onBackPressedDispatcherOwner.

This should only be called by constructs such as activities or dialogs that manage a view tree and handle the dispatch of the system back button. Callers should only set a OnBackPressedDispatcherOwner that will be stable.

Parameters
@NonNull OnBackPressedDispatcherOwner onBackPressedDispatcherOwner

OnBackPressedDispatcherOwner associated with the View