Migrate to the Navigation Architecture Component

The NavController and its navigation graph is contained within a single activity. Therefore, when migrating an existing project to use the Navigation Architecture Component, focus on migrating one Activity at a time by creating a navigation graph for the destinations within each Activity.

Figure 1. Activities and their individual navigation graphs.

Separate Activities can then be linked by adding activity destinations to the navigation graph, replacing existing usages of startActivity() throughout the code base.

Figure 2. Navigation graph in one Activity pointing to second Activity.

In cases where multiple Activities share the same layout, the navigation graphs can be combined, replacing navigate calls to the activity destination to navigate calls directly between the two navigation graphs.

Figure 3. Activity with combined navigation graph.