Home:ALL Converter>Navigation Architecture Component - Activities

Navigation Architecture Component - Activities

Ask Time:2018-05-21T23:47:10         Author:Víctor Albertos

Json Formatter

I've been following the docs from Navigation Architecture Component to understand how this new navigation system works.

To go/back from one screen to another you need a component which implements NavHost interface.

The NavHost is an empty view whereupon destinations are swapped in and out as a user navigates through your app.

But, it seems that currently only Fragments implement NavHost

The Navigation Architecture Component’s default NavHost implementation is NavHostFragment.

So, my questions are:

  • Even if I have a very simple screen which can be implemented with an Activity, in order to work with this new navigation system, a Fragment needs to be hosted containing the actual view?

  • Will Activity implement NavHost interface in a near future?

--UPDATED--

Based on ianhanniballake's answer, I understand that every activity contains its own navigation graph. But if I want to go from one activity to another using the nav component (replacing "old" startActivity call), I can use activity destinations. What is activity destinations is not clear to me because the docs for migration don't go into any detail:

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

  • Is there any benefit on using ActivityNavigator instead of startActivity?
  • What is the proper way to go from activities when using the nav component?

Author:Víctor Albertos,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50452359/navigation-architecture-component-activities
yy