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
6
votes
1 answer

Jetpack Compose: change bottom nav back press behavior with Navigation Components

I finally started using Compose for Android and I am currently stuck at navigation. I have two questions: 1. I have implemented a bottom navigation with three buttons and one of the buttons triggeres a nested navigation graph, like: HOME --- …
6
votes
1 answer

Problem with Android Navigation: Multiple back stacks

My problem is when I try to change the fragment with the bottom navigation it works except in one case. I have 5 fragments, when I enter in the 3rd and after go to the 5th, the icon of the 5th don´t change it color. After that when I do another…
6
votes
1 answer

How to change topBar corresponding screen in Jetpack Compose

I have a Scaffold like this: Scaffold( topBar = { TopBar(...) }, bottomBar = { BottomNavigationBar(...) } ) { NavHost(...) } What is the best way to change TopBar when I navigate to another screen?
6
votes
0 answers

UI Testing Viewpager with NavGraphViewModel using Espresso

I currently have an app which uses a One Activity-Many Fragment approach, and within this app is a fragment which shares significant data with its children, and so I have used navGraphViewModels scoped to a nested nav graph as so: private val…
6
votes
1 answer

Android Compose setupWithNavController

I am looking for a Compose variant of setupWithNavController(Toolbar, NavController) to automatically update the up button in an AppBar whenever the Navigation destination changes. So far I haven't found anything useful. Is it considered a bad…
Antimonit
  • 2,846
  • 23
  • 34
6
votes
1 answer

Navigation Component: Navigate from Fragment in Viewpager to another Fragment

I have a Fragment A which navigates to Fragment B Fragment B hosts a ViewPager2. ViewPager2 has two fragments inflated in it - Fragment C and Fragment D. On clicking an item in Fragment C I want to navigate to a new instance of Fragment D on top of…
6
votes
1 answer

Hide Bottom Navigation View in fragment

I want to hide bottomNavigationView in some fragments. I have tried the below code, but it has a flicker effect. (bottomNavigationView hide before the nextFragment becomes visible. val navController = this.findNavController(R.id.nav_host_home) …
6
votes
1 answer

Android Jetpack Navigation - How to navigate to nested nav graph from drawer menu item

I was curious how one would be able to navigate to a nested navigation graph from a menu item in a drawer layout using the navigation graph from Android Jetpack. I know that there is some magic behind the scenes that links menu items with fragments…
6
votes
0 answers

Android Navigation pop animations not working

I am currently trying to use the Android Navigation component to navigate from one fragment (A) to another (B) by animating fragment B up from the bottom of the screen (over fragment A) and subsequently animating fragment B back down when the back…
6
votes
2 answers

Android navigation. Pop up from nested graph fragment to outer fragment

I have an app module with main navigation graph and feature module with it's own navigation graph. Feature navigation is included to main navigation graph. So feature fragments and navigation graph knows nothing about app module navigation graph. I…
6
votes
4 answers

SafeArgs generated classes (Directions/Args) are not recognized by lint in AS 3.5

I'm migrating several apps to use the Navigation Component, and I ran into a problem - the Directions/Args classes generated by the android-safe-args-gradle-plugin are not being recognized in Android Studio. Code demonstrating this problem is…
6
votes
2 answers

Unable to find NavController that's inside a DialogFragment

I have a BottomSheetDialogFragment that contains a NavHostFragment like so:
6
votes
1 answer

how to back to previous destination programatically using navigation controller in Android?

I have login process like the image below: the user will be navigated from login screen (in the middle) to change password screen (in the right) using the code below: val changePassword =…
6
votes
0 answers

Android Jetpack Navigation Default Transitions for all Actions

I'm developing an app with over 50 screens. At the moment my actions look like that
jakub
  • 3,576
  • 3
  • 29
  • 55
6
votes
3 answers

Android navigation component open url

I have simple code that opens URL in a browser: startActivity(Intent( Intent.ACTION_VIEW, Uri.parse(resources.getString(R.string.application_url)) )) How can I convert this to the navigation component item? Do I need to build custom navigator…