The Migrating Fragments to Jetpack Navigation kotlin development tutorial describes how to take an existing Android app and migrate it to Jetpack Navigation.
This Kotlin on Android development tutorial is based on the previous Kotlin fragment series.
Pre-requisites
Android Jetpack is included in Android Studio 3.2 or later.
Knowledge of the dart programming language is not required, but the experience of an object orientated programming language is recommended. Such as Java, C++, Kotlin, Swift to name a few.
In this Kotlin on Android tutorial we will cover:
- Adding the Navigation Architecture Component
- Creating a Navigation Graph
- Adding Fragments as destinations
- Connecting to destinations
- Adding Navigation Host to Activity
- Connecting to a destination in code
Episodes
Conclusion
This Kotlin on Android development tutorial describes the step for adding the Navigation Architecture component to an existing Android application.
The Navigation Architecture component is now the recommended method of switching between destinations (fragments).
For migrating a current android application first, the Navigation Architecture components must be imported to the Android project.
A navigation graph resource file will be created for hosting the destinations. The navigation resource file is also used to for making connections between destination.
Then the NavHost interface must be added to the activity.
Finally, the FragmentManager methods can be replaced with the NavController methods for navigating to destinations.