Questions tagged [android-navigation]

For questions about navigation within and between Android apps. Examples include navigating between activities/fragments, up/back behavior, task stacks, and Intent flags that affect navigation behavior.

Consistent navigation is an essential component of the overall user experience. Few things frustrate users more than basic navigation that behaves in inconsistent and unexpected ways.

Android 3.0 introduced significant changes to the global navigation behavior. Thoughtfully following the guidelines for Back and Up will make your app's navigation predictable and reliable for your users.

Android 2.3 and earlier relied upon the system Back button for supporting navigation within an app. With the introduction of action bars in Android 3.0, a second navigation mechanism appeared: the Up button, consisting of the app icon and a left-point caret.

See also the official documentation about this topic.

1192 questions
558
votes
32 answers

How to change the status bar color in Android?

First of all it's not a duplicate as in How to change the background color of android status bar How do I change the status bar color which should be same as in navigation bar. I want the status bar color to be same as the navigation bar color
codercat
  • 22,873
  • 9
  • 61
  • 85
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…
204
votes
10 answers

Action bar navigation modes are deprecated in Android L

Taking a look at the API diff report for the Android "L" preview, I see that all methods related to navigation modes in the ActionBar class (such as setNavigationMode(), addTab(), selectTab(), &c). are now deprecated. The documentation…
matiash
  • 54,791
  • 16
  • 125
  • 154
163
votes
38 answers

Android Navigation Architecture Component - Get current visible fragment

Before trying the Navigation component I used to manually do fragment transactions and used the fragment tag in order to fetch the current fragment. val fragment:MyFragment = supportFragmentManager.findFragmentByTag(tag):MyFragment Now in my main…
Alin
  • 14,809
  • 40
  • 129
  • 218
148
votes
28 answers

Safeargs library doesnt generate direction class

I use navigation library and safeargs for passing data. I define argument to fragment like that.
6155031
  • 4,171
  • 6
  • 27
  • 56
102
votes
13 answers

Appcompatv7 - v21 Navigation drawer not showing hamburger icon

I am implementing the lollipop style navigation drawer with latest appcompat support library but the problem is the hamburger icon is never displayed . Only back icon is shown. This is my activity code import android.os.Bundle; import…
Ravi
  • 4,872
  • 8
  • 35
  • 46
96
votes
8 answers

How to detect if navigation drawer is open?

The title explains it all. All what I want to do is to know if the navigation drawer is open or not. I searched a lot on the net and found the method isDrawerOpen(int drawerGravity)but couldn't find a satisfactory answer which explains how to use it…
Chinmay Dabke
  • 5,070
  • 11
  • 40
  • 63
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…
87
votes
4 answers

Setting launchMode="singleTask" vs setting activity launchMode="singleTop"

I have an app that is very hierarchical (activities are similar to League > Team > Position > Player) and so I've made each activity singleTop in order to keep navigation sensible and to prevent duplicate instances. Now I'm making my second app…
NSouth
  • 5,067
  • 7
  • 48
  • 83
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…
79
votes
6 answers

New navigation component from arch with nested navigation graph

I have one case and wish to implement it by arch navigation component. For example I have 2 Nav Graphs (main and nested). Can I call main graph from nested and how?
65
votes
9 answers

FragmentContainerView using findNavController

I'm using Android Navigation Component with bottom navigation, lint gives a warning about replacing the tag with but when i replaced, findNavController is not working it gives me error about it does not have a…
47
votes
1 answer

Multiple Navigation Graphs in Android and Deep Links

I have 3 Activities: Main, Login, Wizard. For each Activity I have separate Navigation Graph with fragment destinations. Main Nav Graph has also Login Activity destination to launch Login screen on logout. App seems to work correctly when…
Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143
46
votes
5 answers

Viewpager2 with fragments and Jetpack navigation: Restore fragments instead of recreating them

I have a Viewpager2 inside a Fragment (lets call it HomeFragment). That Viewpager itself also contains Fragments. When I navigate away from the HomeFragment its view will be destroyed and when I navigate back the view will be recreated. Now I set…
1
2 3
79 80