Questions tagged [android-architecture-navigation]

The Navigation Architecture Component provides a framework for in-app navigation for Android apps.

The Navigation Architecture Component is released as a part of Android JetPack and AndroidX package. It simplifies the navigation implementation in Android Apps. Its goal is to provide consistent and predictable experience to the end users, with single Activity Architecture. It also has support for Fragments and Deep-links. It has Navigation graph at the core of the library. Navigation Graph describes how the activities and fragments are related to each other and how the transition will work.

1346 questions
11
votes
8 answers

NavHostFragment not accessible from XML

I wanted to try new Navigation library. After following this guideline I experienced error at runtime: Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment Caused by:…
10
votes
0 answers
10
votes
4 answers

Android clear backstack when leaving item tab BottomNavigation

I am using the last navigation library (version 2.4.0) which include multiple backstacks with a bottom navigation view. The default behavior is that each backstack is saved when user go back to a tab. I want to clear a backstack when the user leave…
10
votes
4 answers

How to switch to other fragment in different back stack using Navigation Component?

I have 3 bottom navigation tabs called Home, Dashboard, Profile. In Home, I have Fragment1 and Fragment2, In Dashboard, I have Fragment3 and Fragment4 And in Profile, I have MyProfile and EditProfile. Now, in Fragment2, a button changeAvatar can…
10
votes
2 answers

ViewPager2/Tabs problem with ViewModel state

I am following the MVVM pattern - meaning I have a ViewModel for each Fragment. I added two tabs by using ViewPager2. My adapter looks like this: @Override public Fragment createFragment(int position) { switch (position) { case 0: …
10
votes
1 answer

pop up to graph startDestination fragment for a global action - Android navigation components

I've a multi-graph navigation app and I'd like to switch between graphs by using a global action as defined in my root main_graph.xml
10
votes
1 answer

Component Navigation , pop from backstack with arguments

Let's say I have three fragments, A, B, C; A -> B <-> C Between B and C it is a circular relationship. Either B or C fragments requires arguments, example val args = Bundle() args.putString("StringKeyBC", argValueBtoC) …
10
votes
1 answer

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState caused by launchFragmentInContainer

I am trying to test the app workflow. The navigation component has been used to define the app workflow. Have used FragmentScenario for testing the navigation from one fragment to another based on this…
10
votes
1 answer

Deep linking with splash screen and login state

I use Navigation Component. I have app with 2 main parts: 1 splash activity with it's nav_graph 2 main activity with bottom navigation where every menu item has its own nav_graph. The problem is that i cant figure out how to do navigation when…
10
votes
2 answers

Android Navigation Component: How to add a destination programmatically?

I want to inject a new destination to the current nav graph. I notice NavGraph has a method void addDestination(@NonNull NavDestination node) but I can't find a proper way to create a NavDestination and navigate to it using…
Dewey Reed
  • 4,353
  • 2
  • 27
  • 41
10
votes
1 answer

How to return to the root of a navigation graph?

How can I return to the root Fragment using the NavController? I tried navController.popBackStack(navController.graph.startDestination, false) but it did not work. This did work: navController.navigate(navController.graph.startDestination,…
artkoenig
  • 7,117
  • 2
  • 40
  • 61
10
votes
3 answers

Is it possible to change up button icon in Navigation Component?

I would like to change up button icon in ActionBar that is working with Navigation Component. I've tried several options like: supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_arrow_left_blue_24dp) in MainAcitivty or…
10
votes
1 answer

Navigation Component's popUpTo not removing up button

I'm using the Navigation Architecture Component and I have a setup similar to this one for popping the stack when navigating to a particular fragment:
10
votes
1 answer

Gradle sync error using Navigation Component in base module

Using Navigation component alpha09 and have added apply plugin: "androidx.navigation.safeargs" to top of base module build.gradle but getting following error when doing gradle sync. I'm using Android Studio 3.4 Canary 9 (but also had same problem…
John O'Reilly
  • 10,000
  • 4
  • 41
  • 63
10
votes
3 answers

Conditional back navigation with Android Navigation Component

Im making navigation in my app using navigation component from jetpack. I have 3 screens in my app, all of them implemented via Fragment: - search screen - list screen - detail screen When user presses search (on search screen), app navigates…
dhabensky
  • 1,045
  • 8
  • 15