Google is committed to advancing racial equity for Black communities. See how.

TestNavHostController

class TestNavHostController : NavHostController
kotlin.Any
   ↳ androidx.navigation.NavController
   ↳ androidx.navigation.NavHostController
   ↳ androidx.navigation.testing.TestNavHostController

Subclass of NavHostController that offers additional APIs for testing Navigation.

Summary

Inherited constants

Public constructors

<init>(context: Context)

Subclass of NavHostController that offers additional APIs for testing Navigation.

Public methods

Unit
setCurrentDestination(@IdRes destId: Int, args: Bundle = Bundle())

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

Inherited functions

Inherited extension functions

From androidx.navigation
NavGraph
NavController.createGraph(@IdRes id: Int = 0, @IdRes startDestination: Int, builder: NavGraphBuilder.() -> Unit)

Construct a new NavGraph

From androidx.navigation.dynamicfeatures
NavGraph
NavController.createGraph(@IdRes id: Int = 0, @IdRes startDestination: Int, builder: DynamicNavGraphBuilder.() -> Unit)

Construct a new androidx.navigation.NavGraph that supports dynamic navigation destinations

From androidx.navigation.ui
Boolean

Handles the Up button by delegating its behavior to the given NavController.

Boolean

Handles the Up button by delegating its behavior to the given NavController.

Properties

List<NavBackStackEntry>

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

Public constructors

<init>

TestNavHostController(context: Context)

Subclass of NavHostController that offers additional APIs for testing Navigation.

Public methods

setCurrentDestination

@JvmOverloads fun setCurrentDestination(
    @IdRes destId: Int,
    args: Bundle = Bundle()
): Unit

Navigate directly to any destination on the current androidx.navigation.NavGraph via an explicit deep link. If an implicit deep link exists for this destination use #navigateUri instead.

Parameters
destId: Int The destination id to navigate to.
args: Bundle = Bundle() The arguments to pass to the destination.
Exceptions
IllegalArgumentException If the destination does not exist on the NavGraph.

Properties

backStack

val backStack: List<NavBackStackEntry>

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