DynamicFragmentNavigator


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


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

Summary

Nested types

Destination for dynamic feature navigator.

Public constructors

DynamicFragmentNavigator(
    @NonNull Context context,
    @NonNull FragmentManager manager,
    int containerId,
    @NonNull DynamicInstallManager installManager
)

Public methods

@NonNull DynamicFragmentNavigator.Destination

Construct a new NavDestination associated with this Navigator.

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

{@inheritDoc}

Inherited methods

From androidx.navigation.fragment.FragmentNavigator
@NonNull Fragment
instantiateFragment(
    @NonNull Context context,
    @NonNull FragmentManager fragmentManager,
    @NonNull 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

Indicator that this Navigator is actively being used by a NavController.

void

{@inheritDoc}

void
Bundle

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

void
popBackStack(@NonNull NavBackStackEntry popUpTo, boolean savedState)

{@inheritDoc}

From androidx.navigation.Navigator
final @NonNull NavigatorState

The state of the Navigator is the communication conduit between the Navigator and the NavController that has called onAttach.

final boolean

Whether this Navigator is actively being used by a NavController.

NavDestination
navigate(
    @NonNull FragmentNavigator.Destination destination,
    SavedState args,
    NavOptions navOptions,
    Navigator.Extras navigatorExtras
)

Navigate to a destination.

void

Restore any state previously saved in onSaveState.

boolean

Attempt to pop this navigator's back stack, performing the appropriate navigation.

Public constructors

DynamicFragmentNavigator

Added in 2.3.0
public DynamicFragmentNavigator(
    @NonNull Context context,
    @NonNull FragmentManager manager,
    int containerId,
    @NonNull DynamicInstallManager installManager
)

Public methods

createDestination

Added in 2.3.0
public @NonNull DynamicFragmentNavigator.Destination createDestination()

Construct a new NavDestination associated with this Navigator.

Any initialization of the destination should be done in the destination's constructor as it is not guaranteed that every destination will be created through this method.

Returns
@NonNull DynamicFragmentNavigator.Destination

a new NavDestination

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

{@inheritDoc}

This method should always call FragmentTransaction.setPrimaryNavigationFragment so that the Fragment associated with the new destination can be retrieved with FragmentManager.getPrimaryNavigationFragment.

Note that the default implementation commits the new Fragment asynchronously, so the new Fragment is not instantly available after this call completes.

This call will be ignored if the FragmentManager state has already been saved.