onBackPressedDispatcher

Get the current OnBackPressedDispatcher from Fragment.

The current Fragment must be attached to a ComponentActivity.

Receiver

the current Fragment.

Return

OnBackPressedDispatcher

Throws

if the current Fragment is not attached to a ComponentActivity.


Get the current OnBackPressedDispatcher from View.

The current View must be attached to a view tree and hosted by a ComponentActivity.

Receiver

the current View.

Return

OnBackPressedDispatcher

Throws

if the current View is not attached to a LifecycleOwner or its host is not a ComponentActivity.