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
18
votes
4 answers

In Android Navigation Architecture, how can I check if current Fragment is the last one?

I need to display custom AlertDialog, but only when there are no more fragments after calling NavController.navigateUp(). My current code does something similar, but there is a bug to it: override fun onBackPressed() { if…
17
votes
2 answers

Android Navigation Component + Login Flow + Nested BottomNavigationView

I'm struggle building a Navigation, like on the image below, with the Android Navigation Component. I need a "Login Flow", check if the user is logged in and then navigate to the main part of the app (also clearing the backstack). The main part…
17
votes
1 answer

Is it possible to have dynamic destination in Nested Navigation Graph Android?

I have implemented a nested graph in Navigation graph, which is having 2 graphs. In the first graph, there are 3 fragments and in the second graph, there are 2 fragments. Graph 2 is included in graph 1. I want to navigate to (graph 1 step 1) to…
Maddy
  • 4,525
  • 4
  • 33
  • 53
17
votes
8 answers

How to handle back button when at the starting destination of the navigation component

I've started working with the new navigation component and I'm really digging it! I do have one issue though - How am I supposed to handle the back button when I'm at the starting destination of the graph? This is the code I'm using…
17
votes
4 answers

How to highlight the item when pressed using BottomNavigationView between activities?

I have added Bottom Navigation View for my app but I need the Bottom Navigation View between activities instead of fragment so I have added this code to Java for all my 3 activities. When I select Second or Third in my phone all things are correct…
17
votes
0 answers

Android TaskStackBuilder startActivities opens a white screen and freezes sometimes on Samsung Galaxy S3

I am getting a problem when trying to start an activity using the startActivities() method under TaskStackBuilder sometimes on some phones ( Specifically on Samsung Galaxy S3 - Android 4.3 , Samsung Galaxy S3 Neo - Android 4.4.2) Below is the code…
17
votes
3 answers

ViewPager PagerObserver was not registered

My application closes when i turn off my screen and turn it back on. Logcat tells me that the cause of this error is pointing to java line 60 in my CourseFragment.class which extends Fragment. mViewPager.setAdapter(infoTechPageAdapter); I am…
16
votes
2 answers

Fragment savedInstanceState is always null when using Navigation Component

Currently, I am playing around Android Navigation Component with Bottom Navigation Bar. While playing I realized two facts: Fragments are always recreated (onCreate, onViewCreated, onViewDestroyed are called as soon as the user navigates to another…
16
votes
9 answers

Android Navigation Architecture Component: How to pass bundle data to startDestination

I have an activity which has a NavHostFragment. The activity receives certain values in its intent. I want to pass this data to the first fragment i.e startDestination of the navigation graph. I couldn't find any documentation regarding this. I have…
16
votes
6 answers

Block/disable recent apps button

I know that this question was asked before here Android Disable Recent Task Button like in SureLock, but since the answer there is not working, maybe some can share some light on this forgotten mater. I also tried: private void closeRecents() { …
Tazz
  • 781
  • 1
  • 8
  • 23
15
votes
3 answers

How to get a default string value from resources in SafeArgs?

I'm just learning a Android NavigationUI, and try set a toolbar title using string default value from Safe Args. But have some problem about it. 'String resources' file: Add new items Navigation graph…
15
votes
3 answers

NavigationDrawer with Activities vs. NavigationDrawer with Fragments

Take for example the app I'm currently working on: - it has an navigationDrawer with multiple items; there are two items which interest me for now, i'll call them X and Y. both X and Y, when clicked on, display a fragment containing a list of…
14
votes
4 answers

How to prevent BottomSheetDialogFragment from dismissing after a navigation to another fragment?

I am using NavigationComponent on my App. I have an specific flow where after a click on a button of BottomSheetDialogFragment the app should navigate to another fragment. But when that Fragment is popped I need to navigate back to the previous…
14
votes
2 answers

popUpTo seems not to work in Navigation Component

so I'm using the android navigation component and I have a problem (2.2.0-rc04 version). I have a welcomeFragment(wF). From wF I want to navigate to loginSellerFragment(lSF) which is in a different navigation graph. I also don't want to remove wF…
blaffer
  • 143
  • 1
  • 1
  • 7