TestNavHostController
public final class TestNavHostController extends NavHostController
| java.lang.Object | |||
| ↳ | androidx.navigation.NavController | ||
| ↳ | androidx.navigation.NavHostController | ||
| ↳ | androidx.navigation.testing.TestNavHostController |
Subclass of NavHostController that offers additional APIs for testing Navigation.
Summary
Public constructors |
|---|
TestNavHostController(@NonNull Context context) |
Public methods |
|
|---|---|
final @NonNull List<@NonNull NavBackStackEntry> |
Gets an immutable copy of the |
final void |
setCurrentDestination(@IdRes int destId, @NonNull Bundle args)Navigate directly to any destination on the current |
final void |
setCurrentDestination(@NonNull String destRoute, @NonNull Bundle args)Navigate directly to any destination on the current |
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
Public methods
getBackStack
public final @NonNull List<@NonNull NavBackStackEntry> getBackStack()
Gets an immutable copy of the elements currently on the back stack.
setCurrentDestination
public 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. If an implicit deep link exists for this destination use #navigate(Uri) instead.
| Parameters | |
|---|---|
@IdRes int destId |
The destination id to navigate to. |
@NonNull Bundle args |
The arguments to pass to the destination. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If the |
setCurrentDestination
public final void setCurrentDestination(@NonNull String destRoute, @NonNull Bundle args)
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 #navigate(Uri) instead.
| Parameters | |
|---|---|
@NonNull String destRoute |
The destination route to navigate to. |
@NonNull Bundle args |
The arguments to pass to the destination. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If the |