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
23
votes
2 answers

Can I use multiple NavHostFragments in Navigation Component?

Please look at the flowchart I made if you have difficulty in understanding the following paragraph. I'm currently making a notes app with 3 top level destinations. One of the top-level destinations(NotesList) displays a list of notes created by the…
22
votes
3 answers

"Views added to a FragmentContainerView must be associated with a Fragment" with android Nav Component

When nav component switches to a fragment, I get this "Views added to a FragmentContainerView must be associated with a Fragment" crash. What causes this?
kenyee
  • 2,309
  • 1
  • 24
  • 32
22
votes
1 answer

How to set up Navigation Component with Navigation Drawer in Android?

How do I set up navigation component with navigation drawer? How do I use it in my app? Can everything be done with one Activity? How do I handle toolbar visibility with just one Activity and fragments which have a dynamic toolbar visibility. Also,…
22
votes
2 answers

Using the Navigation component with multiple activities

In the Android docs, it states: The Navigation component is designed for apps that have one main activity with multiple fragment destinations. The main activity is associated with a navigation graph and contains a NavHostFragment that is…
Johann
  • 27,536
  • 39
  • 165
  • 279
22
votes
6 answers

Pass data/bundle using navigateUp in Android Navigation Component

I found the question but does not have solution in code I want to have data when backpress/manual back happens. I am using navigateUp() to go back. How can I pass data to previous fragment? navigateUp() does not have any facility to pass data to…
22
votes
2 answers

Adding custom transition animations to bottom navigation setup with jetpack navigation

I am working on an app using jetpack components. I stitched up the bottom navigation with three fragments as described in the guide. However, I can't figure out how to change the transition animation when switching between the fragments on pressing…
22
votes
4 answers

Jetpack navigation: Title and back/up arrow in the action bar?

I have installed the latest canary version of Android Studio, and followed this (https://developer.android.com/topic/libraries/architecture/navigation/navigation-implementing) instruction to implement a simple two page navigation. Basically page1…
22
votes
5 answers

Navigation Architecture Component - New Resource dialog doesn't have Navigation resource type for navigation graph

New Resource dialog doesn't have Navigation resource type for navigation graph even after adding Navigation Architecture Component dependencies def nav_version = '1.0.0-alpha01' implementation…
21
votes
4 answers

Navigating to preference fragment using navigation component

I'm trying to migrate my medium sized app to the new Android navigation component. Currently, my app consists of the single activity and I'm planning on keeping it the same (for that matter); So, I'm facing this issue in which I have a settings…
21
votes
3 answers

View.findNavController() vs Fragment.findNavController()

Anywhere in a NavHostFragment I can do findNavController().navigateUp() Or, if in my Fragment I have a button to be used for navigation, I could do either: editButton.setOnClickListener { v -> …
21
votes
6 answers

Hide android bottom navigation view for child screens/ fragments

I'm trying to create a single activity Android application. I have MainActivity (only activity) with BottomNavigationView, three top level fragments and some child fragments. My requirement is whenever the screen is showing top level fragments,…
21
votes
5 answers

Ignoring navigate() call: FragmentManager has already saved its state

I'm using navigation in MainActivity, then I start SecondActivity (for result). After finish of SecondActivity I would like to continue with navigation in MainActivity, but FragmentManager has saved his state already. On…
21
votes
1 answer

Navigation Component set transition animation programmatically

yesterday i come across with a problem that i needed to set animation from nav_graph.xml in my baseFragment and programatically get action object from current node which includes enterAnim and exitAnim resource. Could not find solution here so here…
21
votes
2 answers

How to write tests for Android Navigation Controller

I'm using the new Navigation Controller which is currently in alpha. It works fine but I can't find any documentation or sample app to see how testing is done. Also google published android.arch.navigation:navigation-testing library for testing…
20
votes
2 answers

Why onViewCreated is called twice in android app using navigation components

I have a simple application with one activity and around 4 fragments. I am using android navigation components. Starting from my splash fragment to next fragments every time fragment is changed, OnCreateview and onViewCreated is called twice, Once…