TestNavHostController

public final class TestNavHostController extends NavController, NavHostController

Object
   ↳ NavController
     ↳ NavHostController
       ↳ TestNavHostController

Subclass of NavHostController that offers additional APIs for testing Navigation.

Summary

Public fields

final @NonNull List<@NonNull NavBackStackEntry>

Gets an immutable copy of the elements currently on the back stack.

Public constructors

Public methods

final void
setCurrentDestination(@IdRes int destId, @NonNull Bundle args)

Navigate directly to any destination on the current androidx.navigation.NavGraph via an explicit deep link.

final void

Navigate directly to any destination on the current androidx.navigation.NavGraph via an explicit deep link.

Inherited methods

From class NavController
void

Adds an OnDestinationChangedListener to this controller to receive a callback whenever the currentDestination or its arguments change.

final @MainThread boolean
clearBackStack(@IdRes int destinationId)

Clears any saved state associated with destinationId that was previously saved via popBackStack when using a saveState value of true.

final @MainThread boolean

Clears any saved state associated with route that was previously saved via popBackStack when using a saveState value of true.

@NonNull NavDeepLinkBuilder

Create a deep link to a destination within this NavController.

@NonNull NavBackStackEntry
getBackStackEntry(@IdRes int destinationId)

Gets the topmost NavBackStackEntry for a destination id.

final @NonNull NavBackStackEntry

Gets the topmost NavBackStackEntry for a route.

@NonNull ViewModelStoreOwner
getViewModelStoreOwner(@IdRes int navGraphId)

Gets the ViewModelStoreOwner for a NavGraph.

@MainThread boolean

Checks the given Intent for a Navigation deep link and navigates to the deep link if present.

@MainThread void
navigate(@NonNull Uri deepLink)

Navigate to a destination via the given deep link Uri.

@MainThread void

Navigate via the given NavDirections

@MainThread void

Navigate to a destination via the given NavDeepLinkRequest.

@MainThread void
navigate(@IdRes int resId)

Navigate to a destination from the current navigation graph.

@MainThread void
navigate(@NonNull Uri deepLink, @Nullable NavOptions navOptions)

Navigate to a destination via the given deep link Uri.

@MainThread void
navigate(
    @NonNull NavDirections directions,
    @Nullable NavOptions navOptions
)

Navigate via the given NavDirections

@