FragmentNavigator

@Navigator.Name(value = "fragment") public class FragmentNavigator extends Navigator

Object
   ↳ Navigator
     ↳ FragmentNavigator
Known direct subclasses
DynamicFragmentNavigator

The Navigator that enables navigating to destinations within dynamic feature modules.


Navigator that navigates through FragmentTransaction. Every destination using this Navigator must set a valid Fragment class name with android:name or Destination.setClassName.

The current Fragment from FragmentNavigator's perspective can be retrieved by calling FragmentManager.getPrimaryNavigationFragment with the FragmentManager passed to this FragmentNavigator.

Note that the default implementation does Fragment transactions asynchronously, so the current Fragment will not be available immediately (i.e., in callbacks to NavController.OnDestinationChangedListener).

Summary

Nested types

FragmentNavigator.Destination

NavDestination specific to FragmentNavigator

FragmentNavigator.Extras

Extras that can be passed to FragmentNavigator to enable Fragment specific behavior

FragmentNavigator.Extras.Builder

Builder for constructing new Extras instances.

Public constructors

FragmentNavigator(
    Context context,
    FragmentManager fragmentManager,
    int containerId
)

Public methods

@NonNull FragmentNavigator.Destination

Construct a new NavDestination associated with this Navigator.

@NonNull Fragment
instantiateFragment(
    Context context,
    FragmentManager fragmentManager,
    String className,
    Bundle args
)

This method is deprecated. Set a custom {@link androidx.fragment.app.FragmentFactory} via {@link FragmentManager#setFragmentFactory(FragmentFactory)} to control instantiation of Fragments.

void
navigate(
    List<NavBackStackEntry> entries,
    NavOptions navOptions,
    Navigator.Extras navigatorExtras
)

{@inheritDoc}

void
onRestoreState(Bundle savedState)

Restore any state previously saved in onSaveState.

Bundle

Called to ask for a Bundle representing the Navigator's state.

void