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

How to find out what the previous fragment was using the navigation component

I am trying to find out what the previous fragment was in the backstack and if it is the one that I want, then go back to that otherwise go to a different fragment. I am having problems finding out the name/id of my previous fragment. My current…
9
votes
0 answers

Android Navigation Component. How to override fragment or action for another build variant without creating new graph

I have 10 flavors(build variants) in gradle and ~50 fragments as Screen. As a result nav_graph is very big (~700 lines). Extending some fragments is a trivial problem, i have 10% extensions for each build variant How to override only a fragment or…
9
votes
6 answers

AndroidX navigation navigateUp twice

I am using the new AndroidX navigation framework. I have a few fragments all linked in a navigation chain. FragmentA --> FragmentB --> FragmentC FragmentC has a Cancel button that should send me up all the way back to FragmentA. Should I do the…
Vasili Fedotov
  • 1,091
  • 14
  • 31
9
votes
5 answers

Tool bar setNavigationOnClickListener breaks ActionbarDrawerToggle functionality

I'm swapping out the action bar for the tool bar, and I nearly have every piece of the puzzle in place. My issue is specifically if I navigate 'up' and restore the navigation drawer, the drawer toggle button no longer works. I figured out if I set…
Daniel Wilson
  • 18,838
  • 12
  • 85
  • 135
9
votes
2 answers

2 ViewPager not scrolling in Android 2.3

I am using Navigation Drawer in my app, that contains some Fragments just like in the below picture. Every Fragment Contains another ViewPager that is an ImageSlider, and below that is a Listview and at the top I am using the SwipeRefreshLayout. My…
8
votes
4 answers

BottomNavigationView's menu not selected after navigating to other fragment, switching to other menu, and switching back to initial menu

I'm building an android application with 3 menus using bottom navigation. I created new project in Android Studio using Bottom Navigation Activity. I renamed the fragment to: InfoFragment.kt DetectFragment.kt AboutFragment.kt Renamed the layout…
8
votes
1 answer

Manually pre-populate navigation backstack in Android/Jetpack Compose

Is it possible to pre-populate the navigation backstack in Android/Jetpack Compose? I have a deeplink, that navigates deep into the navigation hierarchy, however, on back press, it navigates to the root route. Example: Route.Main -> Route.List ->…
8
votes
0 answers

Using NavController with preferences

I'm currently migrating my application to androidX and the new navigation component. My app has different settings screens which are nested into each other. Before androidX the PreferenceScreen were nested into each other. Now days this is handled…
Cilenco
  • 6,951
  • 17
  • 72
  • 152
8
votes
2 answers

Android Navigation Component fragment transitions have white background

I'm using the Jetpack Navigation library and having an issue with the fragment transitions, either if it's a fade or slide animation it always has a white background instead of the previous screen content. fragment A -> fragment B, when the…
8
votes
1 answer

How to clear back stack of Fragments in Navigation Component?

I tried with FragmentManager like this: Navigation.findNavController(mView).popBackStack() And tried using FragmentManager. val fm = activity!!.supportFragmentManager 1. fm.popBackStack() 2. fm.popBackStackImmediate() But They didn't work. I…
c-an
  • 3,543
  • 5
  • 35
  • 82
8
votes
1 answer

Fragment transitions not working in jetpack Navigation framework

Transitions not working even after setting the enter, exit, popEnter and popExit transitions.
Kalyan Dechiraju
  • 1,219
  • 1
  • 11
  • 29
8
votes
2 answers

Android Studio 3.2 canary build is not rendering Navigation tag

Android studio 3.2 canary 14 is not rendering the navigation tag. It just shows the waiting for a build to finish. navigation_graph
8
votes
4 answers

Android Navigation Drawer Remains Highlighted

I am able to navigate from Activity1 to Activity2 via my navigation drawer. But upon pressing the back button at activity2, the option remains highlighted. My Code in activity1 is as followed public boolean onNavigationItemSelected(MenuItem Item) { …
user6487002
8
votes
1 answer

singleTask launchMode in android not working

So, I have 4 activities Activity Activity1, Activity2, Activity3 and Activity4. I start from Activity1 then on some event I start Activity2 then on some event on Activity2 I start Activity3 as a new task as public void onClick(View v) { Intent…
Sushant
  • 1,834
  • 19
  • 32
8
votes
1 answer

How to add draggable icon with navigation drawer

My problem: I want to add draggable icon in navigation drawer. This icon combined with listview of navigation drawer when drawer open. see similar like this, What I have tried, I searched in StackOverflow like similar question this, Draggable…