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
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
6 answers

How to refresh list of the navigation drawer as soon as its open/closed in Android

I have created navigation drawer and displaying items in list. My list is static but i am displaying points. So when users select the items in the list and do some activity he get the points. So i want to update the points as soon as he gets. How…
rupesh
  • 2,865
  • 4
  • 24
  • 50
11
votes
2 answers

"error: package R does not exist" in Navigation after adding Assets folder: Android Studio

Since adding an Assets folder to my project I now get: error: package R does not exist "return new ActionOnlyNavDirections(R.id.action_newAlarmFragment_to_homeFragment);" which is from this auto generated code: import…
Joe Pleavin
  • 436
  • 1
  • 4
  • 21
11
votes
3 answers

Jetpack compose navigation with multiple optional argments

https://developer.android.com/jetpack/compose/navigation#optional-args been going through documentation to figure out how to use multiple optional arguments and how to pass them but in docs only one param is mentioned. composable( …
11
votes
2 answers

How to navigate with nested navGraph and bottom navigation view

I've bottom nav view with 3 item, My navGraph looks like this:
11
votes
1 answer

How to hide actionbar in some fragments with Android Navigation Components?

I am using android navigation components to navigate fragments. I can easily set action bar by using this code in the Main Activity : NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); …
11
votes
1 answer

Android navigation component - navigating between included graphs of modules

I have a single activity application with 3 modules - app, list & detail. My activity is in app module, it's hosting the only NavHostFragment. All modules have their own navigation graphs. detail's starting point requires a long parameter. app's…
11
votes
2 answers

Espresso test Fail

I am doing some Espresso testing in Android. The test is failing with this error: java.lang.ClassCastException: androidx.fragment.app.testing.FragmentScenario$EmptyFragmentActivity cannot be cast to…
11
votes
5 answers

How to prevent previous fragment to show up after pressing back button using navigation controller?

I am trying to use the navigation controller right now. I want to move from LoginFragment to HomeFragment. In LoginFragment I use this code below to move to HomeFragment. Navigation.findNavController(view).navigate(homeDestination) However, when I…
11
votes
2 answers

Android Jetpack Navigation proper back stack with BottomNavigationView

OBS: Though still no first class support (as of writing this), Google has now updated their samples with an example of how they think this should be solved:…
11
votes
1 answer

Recreating backstack with Android Navigation Architecture Component

I am trying to implement navigation to specific Detail pages of my app using PendingIntent from a notification, however I am having problems recreating the backstack from the Detail page all the way back to the start destination. I made a sample app…
11
votes
2 answers

Navigation component pop behavior is not working as it should

Inside an app I'm building I have used the single activity architecture and decided to use Google's new Navigation component to navigate around the app. Though it's showing great promise, it has some drawbacks which my question is about one of…
11
votes
11 answers

Navigation drawer doesn't close

The navigation drawer in my app is not closing. I am using activities instead of fragments. When i click on any item in the listview, it opens other activities as it should but when i go back, the drawer is still open. I have tried using…
Chinmay Dabke
  • 5,070
  • 11
  • 40
  • 63
11
votes
3 answers

How do I add navigation drawer to my existing code?

I have an app in which I have a navigation panel with menu buttons on which I want to apply navigation drawer, currently it takes up the entire screen,but I want to restrict it to 3/4th of the screen by applying navigation drawer on it, but i have…
user2386226
11
votes
7 answers

Android: wrong transition when using navigateUpFromSameTask()

I'm just starting out with Android and I followed this guide on adding the Up navigation to an Activity on the Action Bar. http://developer.android.com/training/implementing-navigation/ancestral.html However, the transition of when I use the up…
Linkandzelda
  • 611
  • 14
  • 24