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
38
votes
5 answers

Fragment Not Associated With A Fragment Manager

I am writing some instrumented tests for an app with one activity and multiple fragments using the Navigation Component. The code for my splash screen is as below: class SplashFragment : Fragment(), KodeinAware { override val kodein by…
38
votes
4 answers

Navigation Component prevent to recreate fragment on back press

I'm using the Jetpack Navigation Component in my project with a single activity and some fragments. I have a fragment with a list that fills from server side. I call getDataFromServer on the onViewCreated method then, when a user clicks on an item,…
38
votes
4 answers

Passing argument(s) to a nested Navigation architecture component graph

How does one pass argument(s) to a nested Navigation architecture component graph? Let's say I construct my navigation graph to navigate from FragmentA --> Nested, where Nested contains FragmentB --> FragmentC... If this was a pure FragmentA -->…
37
votes
3 answers

Multi-module Navigation with Architecture Components

So I have this structure for my modules in my current app. I haven't found any official documentation on multi-module navigation yet but I found this article regarding this so here's how my gradle files are: Feature 1 - Detail ... implementation…
36
votes
3 answers

Only allow one instance when navigate with NavController

I'm currently using Android Navigation Architecture in my project. It has a feature that can launch any fragment with a shortcut. Currently I'm using NavController to navigate to desired destination when clicking at a shortcut. But when I clicked a…
36
votes
5 answers

Android Jetpack Navigation with ViewPager and TabLayout

For a new app i use Jetpack Navigation Library to implement proper back navigation. The first level of navigation is a navigation drawer which works fine with jetpack navigation as described in the documentation. But there is another level of…
33
votes
3 answers

Navigation Architecture Component - Detail View with CollapsingToolbar

The proposed practise for the new navigation components were presented at I/O with the following template and proposed philosophy: One Activity for an App Activity contains Toolbar and Bottom Navigation Bar A typical app often has a detail view…
31
votes
3 answers

Navigation Component, Control when to show hamburger or back icon

I have the following Activity class MainActivity : AppCompatActivity() { private lateinit var drawerLayout: androidx.drawerlayout.widget.DrawerLayout override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) …
30
votes
6 answers

Custom "navigate up" behavior for certain fragment using Navigation component

I want to add custom up navigation from fragment using Navigation component In my build.gradle(app) I use androidx.appcompat:appcompat:1.1.0-alpha04 dependency to have access to onBackPressedDispatcher from activity. So I implemented…
30
votes
3 answers

Safe Args: use list of parcelables

I am using the Safe Args plugin with the new Navigation components for my Android project. Now I have an argument that is an array list of parcelables, is there a way to use this with the Safe Args Plugin? Something like app:argType=ParcelableArray.…
botflot
  • 275
  • 1
  • 4
  • 9
28
votes
4 answers

How to use Navigation Drawer and Bottom Navigation simultaneously - Navigation Architecture Component

I have screen like below which contain a navigation drawer and bottom navigation on same screen: I am using Jetpack Navigation Architecture Component. Current issue and What I have tried? Clicking on the 2nd and 3rd bottom nav item shows back arrow…
user158
  • 12,852
  • 7
  • 62
  • 94
28
votes
4 answers

Navigation Component .popBackStack() with arguments

I have Two fragment. SecondFragment and ThirdFragment. Actually I use the Navigation Component for passing value between fragments. Like this: SecondFragment: val action =…
vihkat
  • 895
  • 3
  • 13
  • 28
27
votes
9 answers

Cause: androidx.navigation.safeargs can only be used with an androidx project

I am facing issue with navigation component called safeargs. I have used classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.0.0' in build gradle. While applying plugin androidx.navigation.safeargs.kotlin in app/build.gradle, I am…
26
votes
2 answers

How to listen to Fragment Change in Navigation Component?

How can I add Fragment Change Listener in new Navigation Component? I have a BottomNavigationView in which I used new Navigation Component following official sample I have four destinations in my BottomNavigationView, all of them have their…
musooff
  • 6,412
  • 3
  • 36
  • 65
26
votes
9 answers

How to scope a view model to a parent fragment?

So I'm using the new navigation component (with the one activity principle) and communicating between each fragment using shared view models, however, I've come to a point where I sometimes need to clear the view model but I can't find a good place…
1 2
3
89 90