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
285
votes
21 answers

How to clear navigation Stack after navigating to another fragment in Android

I am using The new Navigation Architecture Component in android and I am stuck in clearing the navigation stack after moving to a new fragment. Example: I am in the loginFragment and I want this fragment to be cleared from the stack when I…
224
votes
40 answers

IllegalArgumentException: navigation destination xxx is unknown to this NavController

I am having an issue with the new Android Navigation Architecture component when I try to navigate from one Fragment to another, I get this weird error: java.lang.IllegalArgumentException: navigation destination XXX is unknown to this…
166
votes
21 answers

IllegalStateException: Link does not have a NavController set

I'm using Android Navigation Component for Navigation. I have a LoginFragment which has a button to transition to SignUpFragment. On clicking the button I'm getting this error. java.lang.IllegalStateException: View…
140
votes
10 answers

Unable to load class AndroidComponentsExtension after upgrading the Android Gradle Plugin 7.1

I recently downloaded Android Studio Bumblebee and it helpfully asked whether I wanted to upgrade to Android Gradle Plugin 7.1.0, the version that shipped alongside Android Studio Bumblebee. After upgrading, I get a build error: Unable to load class…
120
votes
10 answers

Fragments destroyed / recreated with Jetpack's Android Navigation components

I'm trying to implement Navigation with Jetpack's architecture components in my existing app. I have a single activity app where the main fragment (ListFragment) is a list of items. Currently, when the user taps on a list item a second fragment is…
115
votes
9 answers

How to get a result from fragment using Navigation Architecture Component?

Let's say that we have two fragments: MainFragment and SelectionFragment. The second one is build for selecting some object, e.g. an integer. There are different approaches in receiving result from this second fragment like callbacks, buses etc.…
96
votes
12 answers

Navigation Architecture Component- Passing argument data to the startDestination

I have an activity A that start activity B passing to it some intent data. Activity B host a navigation graph from the new Navigation Architecture Component.I want to pass that intent data to the startDestination fragment as argument how to do that?
95
votes
5 answers

Is it possible to set startDestination conditionally using Android Navigation Architecture Component(Android Jetpack)?

I am using Navigation from Android Jetpack to navigate between screens. Now I want to set startDestination dynamically. I have an Activity named MainActivity And two Fragments, FragmentA & FragmentB. var isAllSetUp : Boolean = // It is dynamic and…
95
votes
8 answers

How to change start destination of a navigation graph programmatically?

Basically, I have the following navigation graph: I want to change my starting point in navigation graph to fragment 2 right after reaching it (in order to prevent going back to fragment 1 when pressing back button - like with the splash…
88
votes
16 answers

Dynamic ActionBar title from a Fragment using AndroidX Navigation

I am using the new Navigation component from Android Jetpack. The root Activity setup is quite simple: override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) …
Jonas Schmid
  • 5,360
  • 6
  • 38
  • 60
87
votes
12 answers

Plugin with id 'androidx.navigation.safeargs' not found

When I try to add Safe Args (Android Navigation) to my app's as following ( using this guide : https://developer.android.com/topic/libraries/architecture/navigation/navigation-pass-data ) : apply plugin: 'com.android.application' apply plugin:…
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
81
votes
8 answers

Add (not replace) fragment with navigation architecture component

I have an activity with a product list fragment and many other fragments and I am trying to use architecture component navigation controller. The problem is: it replaces the (start destination) product list fragment and I don't want the list to be…
81
votes
14 answers

Android Jetpack Navigation, BottomNavigationView with Youtube or Instagram like proper back navigation (fragment back stack)?

Android Jetpack Navigation, BottomNavigationView with auto fragment back stack on back button click? What I wanted, after choosing multiple tabs one after another by user and user click on back button app must redirect to the last page he/she…
72
votes
10 answers

Navigation Architecture Component - Dialog Fragments

Is it possible to use the new Navigation Architecture Component with DialogFragment? Do I have to create a custom Navigator? I would love to use them with the new features in my navigation graph.
68
votes
3 answers

Navigation Preview unavailable in Android Studio 3.2 Preview

I am interested to try the Navigation graph showed in the Android Studio. But I got the preview unavailable after I import the google sample I used the Android Studio 3.2 Preview Canary 16
1
2 3
89 90