For the More Curious: Navigation Architecture Component Library

As you have seen, there are several ways of navigating users through your app. You can have multiple activities, one for each screen, and start them as the user interacts with your UI. You can also go with a single activity that hosts several fragments that make up your UI instead.

In an effort to simplify app navigation, the Android team introduced the Navigation architecture component library as part of Jetpack. This library simplifies the implementation of your navigation by providing a GUI-based editor where you can configure your navigation flow (Figure 12.4).

Figure 12.4  Navigation editor

Navigation editor

The Navigation library is opinionated about how you should implement navigation in your project. It prefers navigation using fragments with a single activity over using an activity for each screen. You can provide the arguments your fragments need directly in the navigation editor tool.

For a big challenge, create a copy of CriminalIntent and implement the app’s navigation using the Navigation architecture component (developer.android.com/​topic/​libraries/​architecture/​navigation). The documentation will be very useful on your journey. There are many parts involved, but once your setup is complete it is simple to add new screens to your app and hook up the actions between them.

As of this writing, the stable version of the Navigation architecture component was just officially released. The timing did not allow us to incorporate it into this edition, but this tool has major promise, and we believe it will be the way of the future for many Android developers. We recommend you try it out and see what you think. We are in the process of doing that as well.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.247.196