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
12
votes
4 answers

Android SafeArgs generated action is missing arguments

My project uses SafeArgs. I've switched to a branch that someone else created, and building the project generates a compiler error, because the generated "~Directions" class' methods for return ActionOnlyNavDirections (no arguments passed to…
duggulous
  • 2,427
  • 3
  • 23
  • 40
12
votes
3 answers

Fragment has null arguments safeargs

How can I pass argument to dialog fragment using the navigation architecture component safeargs? below is my current implementation Start Fragment val navController = findNavController() val action = …
Ismail
  • 445
  • 1
  • 5
  • 20
12
votes
3 answers

Accessing graph-scoped ViewModel of child NavHostFragment using by navGraphViewModels

I am using the Navigation Component of Android Jetpack (2.2.0-alpha01). I wish to use a child NavHostFragment nested inside my main NavHostFragment, equipped with its own child nav graph. Please view the following image for context: The child nav…
12
votes
4 answers

OnBackPressedCallback is being called, but app is not going back

I recently updated my dependencies to include the OnBackPressedCallback change from an interface into an abstract class. I have set things up according to the new documentation here but I feel like things are not working as they should. My…
12
votes
2 answers

How to navigate from Dialog to Fragment in Navigation Component?

I am trying to navigation from DialogFragment to Fragment in Navigation Component, but getting weird result. When I navigate from DialogFragment to Fragment, background fragment is changing to target fragment with current dialog on top of it,…
12
votes
1 answer

Android Navigation Component - Navigate up opens the same fragment

I'm having a problem where when executing findNavController(R.id.main_nav_host).navigateUp() or findNavController(R.id.main_nav_host).popBackStack() Instead of going back to the last fragment in the backstack, it reopens/navigates to the…
12
votes
3 answers

Navigation component with instant/(dynamic-)feature modules

I'm trying to implement the new navigation component with dynamic features So the structure looks like this: app (has dynamic dynamicFeatures = [] included in gradle) features login home etc. library -> globalNav I've been reading a lot with no…
12
votes
2 answers

How to pass a List as an argument to a Fragment using Navigation Component safeargs

The documentation discusses how to send simple integers and strings. For example: In the origin Fragment: val action =…
JHowzer
  • 3,684
  • 4
  • 30
  • 36
12
votes
2 answers

Shared viewmodel between fragments, without scoping to the activity?

Using the new Navigation Architecture Component, I've got a single activity as a navhost with multiple fragments for my screens. Right now I have an EditProfileFragment where the user can click a button and another fragment opens, with a list of…
12
votes
4 answers

Navigation destination unknown to this NavController after an activity result

i'm using nav controller 1.0.0alpha05 and it is working great, but i'm struggling with this dreaded error when i execute a navigation action after an activity result. I have a single activity/multiple fragments structure, in particular a fragment…
12
votes
1 answer

Coordinate Back Button ownership in Nested Navigation Controllers

I have a main screen that shows the general information of the app, and a bottom sheet with additional information. The main screen content can change if the user clicks something on the navigation drawer menu, selecting a new screen. The bottom…
11
votes
4 answers

Missing mutability flags: Android 12 pending intents with NavDeepLinkBuilder

I´ve started testing my app for issues on Android 12, and have had some warnings regarding mutability flags on pending intents that are set up for a home screen widget. These mutability flags are now mandatory from SDK 31. Before 31, this code would…
11
votes
2 answers

LiveData observer is being triggered multiple times using Navigation Component

Scenario: I have two fragments named FirstFragment and UnitFragment. I go from FirstFragment to UnitFragment to select a unit to come back to FirstFragmet using navController.popBackStack(); and send unit data to FirstFragment which is observing…
11
votes
1 answer

Navigating out of ViewPager tab using Navigation Components

First, some clarifications. After looking at a lot of other related questions let's start with what this is not: This is not about BottomNavigation This is not about operating the ViewPager using Navigation Components (like this one) This…
11
votes
1 answer

ViewPager2 inside a fragment leaks after replacing the fragment it's in by Navigation Component navigate

At first, i had the issue for ViewPager2 inside a tab of BottomNavigationView and data binding , data binding also leaks with ViewPager2 and should be nulled in onDestroyView, leaking and managed to narrow the issue to ViewPager2 while navigating…