Search⌘ K
AI Features

Working with the Navigation Component

Explore how to implement the Android Jetpack Navigation Component to manage complex app navigation. Learn to define navigation graphs, use NavHost containers, and NavController to navigate between fragments effectively, improving user experience and app structure.

Introduction

Android Jetpack provides the Navigation Component library, which lets us handle all the navigation scenarios in the app. It standardizes how navigation is dealt with across different components in the app and allows us to build a consistent experience.

Navigation components

  • Navigation graph: This is an XML resource file containing all navigation destinations and details of paths to reach them. Navigation graphs are specific to the activity and are defined under the res/navigation directory.

  • NavHost: This is a container that displays all fragment destinations. The library contains the NavHostFragment, which is the default implementation of the NavHost.

  • NavController: ...