Skip to content

Jetpack Navigation

Devrath edited this page May 1, 2021 · 3 revisions

What is Jetpack navigation

  • This component handles the user-app journey. When the user navigates in the application, the user will go from one screen to another screen based on the complexity of the application.
  • Earlier we used to use intents to move from screen to screen and the arguments to pass the data along with it, Now navigation makes it much simple.
  • It uses the pattern where there is one activity and multiple fragments.
  • It creates classes in the background and via calling functions, we can move from screen to screen.
  • It handles complex cases like bottom tabbed navigation and App drawers, These navigation is handled in a seamless way and developers do not have to worry about it.

Benifits of jetpack Navigation

  • Handles fragment transaction by avoiding inconsistencies and memory leaks
  • Handles device back and up buttons
  • Handles back-stack
  • Handles argument passing
  • takes care of transitions animations
  • Easy way to implement deep-linking

How does it work

  • In the image above we can see that there is a representation of flow based on user actions.
  • There is an activity -> This activity has a container for the fragment -> all the screen flows reside in this container
  • In the image above title_screen and based on the user action there can be two possibilities of navigation and so on.
  • Here the important thing to note is backstack and navigation are taken care of by the library, no matter how complex the navigation hierarchy is, a developer can rely on the navigation library.

Demo represents how the navigation is used in