Google은 흑인 공동체를 위한 인종 간 평등을 진전시키기 위해 노력하고 있습니다. Google에서 어떤 노력을 하고 있는지 확인하세요.

NavController

open class NavController
kotlin.Any
   ↳ androidx.navigation.NavController

NavController manages app navigation within a NavHost.

Apps will generally obtain a controller directly from a host, or by using one of the utility methods on the Navigation class rather than create a controller directly.

Navigation flows and destinations are determined by the navigation graph owned by the controller. These graphs are typically inflated from an Android resource, but, like views, they can also be constructed or combined programmatically or for the case of dynamic navigation structure. (For example, if the navigation structure of the application is determined by live data obtained' from a remote server.)

Summary

Nested classes
abstract

OnDestinationChangedListener receives a callback when the getCurrentDestination() or its arguments change.

Constants
static String

The Intent that triggered a deep link to the current destination.

Public constructors
<init>(@NonNull context: Context)

Constructs a new controller for a given Context.

Public methods
open Unit

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

open NavDeepLinkBuilder

Create a deep link to a destination within this NavController.

open NavBackStackEntry
getBackStackEntry(@IdRes destinationId: Int)

Gets the topmost NavBackStackEntry for a destination id.

open NavBackStackEntry?

Gets the topmost NavBackStackEntry.

open NavDestination?

Gets the current destination.

open NavGraph

Gets the topmost navigation graph associated with this NavController.

open NavInflater

Returns the inflater for this controller.

open NavigatorProvider

Retrieve the NavController's NavigatorProvider.

open NavBackStackEntry?

Gets the previous visible NavBackStackEntry.

open ViewModelStoreOwner
getViewModelStoreOwner(@IdRes navGraphId: Int)

Gets the ViewModelStoreOwner for a NavGraph.

open Boolean
handleDeepLink(@Nullable intent: Intent?)

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

open Unit
navigate(@IdRes resId: Int)

Navigate to a destination from the current navigation graph.

open Unit
navigate(@IdRes resId: Int, @Nullable args: Bundle?)

Navigate to a destination from the current navigation graph.

open Unit
navigate(@IdRes resId: Int, @Nullable args: Bundle?, @Nullable navOptions: NavOptions?)

Navigate to a destination from the current navigation graph.

open Unit
navigate(@IdRes resId: Int, @Nullable args: Bundle?, @Nullable navOptions: NavOptions?, @Nullable navigatorExtras: Navigator.Extras?)

Navigate to a destination from the current navigation graph.

open Unit
navigate(@NonNull deepLink: Uri)

Navigate to a destination via the given deep link Uri.

open Unit
navigate(@NonNull deepLink: Uri, @Nullable navOptions: NavOptions?)

Navigate to a destination via the given deep link Uri.

open Unit
navigate(@NonNull deepLink: Uri, @Nullable navOptions: NavOptions?, @Nullable navigatorExtras: Navigator.Extras?)

Navigate to a destination via the given deep link Uri.

open Unit
navigate(@NonNull request: NavDeepLinkRequest)

Navigate to a destination via the given NavDeepLinkRequest.

open Unit
navigate(@NonNull request: NavDeepLinkRequest, @Nullable navOptions: NavOptions?)

Navigate to a destination via the given NavDeepLinkRequest.

open Unit
navigate(@NonNull request: NavDeepLinkRequest, @Nullable navOptions: NavOptions?, @Nullable navigatorExtras: Navigator.Extras?)

Navigate to a destination via the given NavDeepLinkRequest.

open Unit
navigate(@NonNull directions: NavDirections)

Navigate via the given NavDirections

open Unit
navigate(@NonNull directions: NavDirections, @Nullable navOptions: NavOptions?)

Navigate via the given NavDirections

open Unit
navigate(@NonNull directions: NavDirections, @NonNull navigatorExtras: Navigator.Extras)

Navigate via the given NavDirections

open Boolean

Attempts to navigate up in the navigation hierarchy.

open Boolean

Attempts to pop the controller's back stack.

open Boolean
popBackStack(@IdRes destinationId: Int, inclusive: Boolean)

Attempts to pop the controller's back stack back to a specific destination.

open Unit

Removes an OnDestinationChangedListener from this controller.

open Unit
restoreState(@Nullable navState: Bundle?)

Restores all navigation controller state from a bundle.

open Bundle?

Saves all navigation controller state to a Bundle.

open Unit
setGraph(@NavigationRes graphResId: Int)

Sets the navigation graph to the specified resource.

open Unit
setGraph(@NavigationRes graphResId: Int, @Nullable startDestinationArgs: Bundle?)

Sets the navigation graph to the specified resource.

open Unit
setGraph(@NonNull graph: NavGraph)

Sets the navigation graph to the specified graph.

open Unit
setGraph(@NonNull graph: NavGraph, @Nullable startDestinationArgs: Bundle?)

Sets the navigation graph to the specified graph.

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