Android Jetpack: Manage UI navigation with navigation controller (Google I/O '18)

Android Developers · 102K views · 2018 · 33:52

Open on YouTube

Software (other)Software architecture & designtalkdated

Why Stack Overflow recommends it

Stack Overflow users link it as the primary source for how the Navigation component works, its single-Activity philosophy, and how to wire it to the ActionBar and Android Studio's editor.

Recommended by 4 people across 4 different months, 2018 to 2019.

What it is

A Google I/O 2018 session from the Android team introducing the Navigation Architecture Component in Jetpack. It shows how to define a navigation graph with the Navigation Editor in Android Studio, XML or the Java API, and how that simplifies in-app navigation and deep linking.

What people said

Recommends TapanHP · 2018-05 · Stack Overflow · on “What exactly is Android Jetpack?”

Basically it is just set of useful things combined and sorted under 4 categories Foundation Architecture Behavior UI Some of the core things like AppCompat library, Architecture components, Fragments, Animation and transitions and many more were added now in relative categories and these 5 things were newly added. Android Ktx [LINK] The purpose of Android KTX is to make Android development with Kotlin more concise, pleasant, and idiomatic by leveraging Kotlin language features such as extension functions/properties, lambdas, named parameters, and parameter default values Navigation [LINK] The Navigation Architecture Component simplifies the implementation of navigation in an Android app.This

Recommends zsmb13 · 2018-06 · Stack Overflow · on “Android Navigation Architecture Component - Is Navigation Architecture Component meant to use Single Activity Only?”

In theory, the Navigation library supports any architecture you might want to use. Out of the box it can handle Activities and Fragments as navigation destinations, but you can plug in your own solution by implementing your own Navigator [LINK] (as an example, see this article [LINK] ). However, quoted / paraphrased from the Google I/O talk on Navigation [this video] : What is my Activity actually meant to do? Right now, some apps are very Activity-heavy, some are Fragment-heavy, or completely in a different system. We're moving towards a model where the Activity is more just an entry point into your app, rather than it being the owner of the content of your app. It's actually just going to store

Recommends Tobias · 2018-07 · Stack Overflow · on “Android: How can you pre-populate the fragment backstack?”

I solved this by just committing multiple fragment transactions. Works for me supportFragmentManager.beginTransaction().replace(R.id.content, Fragment1(), "f1").addToBackStack(null).commit() supportFragmentManager.beginTransaction().replace(R.id.content, Fragment2(), "f2").addToBackStack(null).commit() supportFragmentManager.beginTransaction().replace(R.id.content, Fragment3(), "f3").addToBackStack(null).commit() supportFragmentManager.beginTransaction().replace(R.id.content, Fragment4(), "f4").commit() However, for a cleaner and better solution you could also have a look at the Jetpack Navigation UI [this video]

Recommends MD Naseem Ashraf · 2019-03 · Stack Overflow · on “Android Activity history tracking and clearing partially”

Also, look at newer available methods and tools for app navigation. You can start including these into your project; [LINK] [LINK] [LINK] [this video]

Cites Rahul Katte · 2018-05 · Stack Overflow · on “No Navigation Editor in android studio”

I'm trying to work on this new navigation editor introduced as a part of architecture components recently. reference : [this video] I added the depdencies as mentioned in the documentation [LINK] My assumption is that there is a new 'Resource Type' called 'Navigation' introduced. And when I add a 'Navigation' file in my project, android studio will let me view that file in two modes, text and design and I thought that the design mode is the 'Navigation Editor' I tried what was given in the documentation. [LINK] Right click the 'res' folder -> new resource file -> resouce type - 'Navigation'. But, I could not find a resouce type called 'Navigation' However I was able to create a resource directory

Cites ianhanniballake · 2018-07 · Stack Overflow · on “Jetpack navigation: Title and back/up arrow in the action bar?”

You can connect your ActionBar to a NavController using NavigationUI.setupActionBarWithNavController() [LINK] . This is generally done in your Activity, right after you call setSupportActionBar() : supportActionBar = findViewById<Toolbar>(R.id.toolbar) // Get the NavController for your NavHostFragment val navController = findNavController(R.id.nav_host_fragment) // Set up the ActionBar to stay in sync with the NavController setupActionBarWithNavController(navController) This approach is covered in the Navigation talk at Google I/O 2018 [this video] .