Recall & Review
beginner
What is a NavHost in Android navigation?
A NavHost is a container that displays destinations (screens) managed by a NavController. It acts like a frame where different screens appear as you navigate.
Click to reveal answer
beginner
What role does the NavController play in Android navigation?
NavController controls app navigation within a NavHost. It lets you move between screens, handle back actions, and manage navigation state.
Click to reveal answer
intermediate
How do you connect a NavController to a NavHost in Kotlin?
You get the NavController from the NavHostFragment using: val navController = findNavController(R.id.nav_host_fragment). This links navigation actions to the NavHost.
Click to reveal answer
beginner
What is a navigation graph in Android navigation?
A navigation graph is an XML file that defines all possible destinations (screens) and actions (transitions) between them. It guides the NavController on where to go.
Click to reveal answer
intermediate
Why is using NavHost and NavController better than manual fragment transactions?
They simplify navigation by managing the back stack automatically, reducing code, and making navigation predictable and easier to maintain.
Click to reveal answer
What does a NavHost do in an Android app?
✗ Incorrect
A NavHost is a container that shows the current screen and manages navigation destinations.
Which class controls navigation actions like moving between screens?
✗ Incorrect
NavController handles navigation actions such as moving between destinations.
How do you get a NavController instance in an Activity?
✗ Incorrect
You get NavController by calling findNavController with the NavHostFragment's ID.
What file defines the navigation paths and destinations?
✗ Incorrect
The navigation graph XML defines destinations and navigation actions.
Which benefit does NavController provide over manual fragment transactions?
✗ Incorrect
NavController automatically manages the back stack, simplifying navigation.
Explain how NavHost and NavController work together to manage navigation in an Android app.
Think of NavHost as a stage and NavController as the director.
You got /4 concepts.
Describe the steps to set up navigation using NavHost and NavController in a Kotlin Android app.
Start from layout, then code, then navigation actions.
You got /4 concepts.