Questions tagged [fragment-backstack]

Akin to the Android Activity backstack, the Fragment backstack is a task-like stack of Fragments (specified when adding a Fragment to a page with FragmentManager). It allows a linear navigation backwards from the current visible fragment, back through a history of previous fragments in a container until you reach the base fragment.

Akin to the Android Activity backstack, the Fragment backstack is a task-like stack of Fragments (specified when adding a Fragment to a page with FragmentManager). It allows a linear navigation backwards from the current visible fragment, back through a history of previous fragments in a container until you reach the base fragment.

Links

357 questions
1
vote
2 answers

3rd Fragment override 1st on backPress, when don't use addToBackStack in 2nd fragment

I open fragments like this: [1]+with addToBackStack) > [2](without addToBackStack) > [3] in Fragment 3 when click onBackPress Button then 2nd is not visible but 3rd override 1. If I use addToBackStack in 2nd fragment also, then everything is…
1
vote
0 answers

"Deep-link" to a fragment while using the app - Navigation Component

Suppose for simplicity that an App consists of 3 screens (Home, Account, Payments) and these are hosted inside a Navigation Graph. When pressing a button in Home screen, user navigates to Account screen. When pressing a button in Account screen,…
1
vote
1 answer

How to fix OnBackPressedCallback if it doesn't work in Fragment?

Here I override handleOnBackPressed() method: Log.d("Fragment", "onViewCreated") requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) { object : OnBackPressedCallback(true) { override fun…
1
vote
1 answer

Navigation Component: How to pop back to previous destination after navigate to a destination using deep link?

I navigate to a destination using deep link in another navigation graph Navigation.findNavController(view).navigate(Uri.parse(link)); And I just want to return to the previous destination. However, popBackStack() only restart the deep link…
1
vote
1 answer

Android onBackPressed adds Fragment instead of replacing

In my app, I have a TopActionBar fragment that is loaded on the MainActivity that loads a MaterialToolbar, along with my navigation drawer. I have a FrameLayout in this fragment that I replace with fragments to navigate between pages. When I replace…
1
vote
1 answer

How do I implement that a fragment doesn't get saved onto the backstack?

I work on an app and this app has a list fragment as the starting point when you open the app. Now when I click on a listItem an update fragment opens and when you press the save button you go back to the list fragment. The problem is that when I…
1
vote
0 answers

Why `supportFragmentManager.backStackEntryCount` is empty after `add()` fragment to stack

In Android app (Kotlin) I have Activity with container what have fragment A in it. On user interaction, I am adding fragment B to container by: supportFragmentManager.commit { add(container, fragmentB, tag) } Why when I go back in stack…
Baterka
  • 3,075
  • 5
  • 31
  • 60
1
vote
2 answers

Issue with backstack and bottomnav in kotlin

I have a bottom nav with 4 fragments Home, Following, Notification, and Profile, there is no issue with the bottom navigation on backstack , but now for eg from profile fragment I jumped to a fragment called edit_profile which is not a part of the…
1
vote
3 answers

Navigate up from activity to fragment open the same fragment - Android Navigation Component

on this app, When I trying to navigate from "HomeFragment" to "DetailsActivity"then pressed back it's back to the same fragment and also the hamburger icon on click doesn't work nav grpah
1
vote
0 answers

Create Instagram like bottom navigation with separate backstack

I'm new to android development and need some guidance. I'm trying to implement functionality like Instagram Bottom Navigation. Let me describe what do I mean by the functionality. Desired Functionality Bottom Navigation should display persistently…
1
vote
0 answers

How to handle the back stack of bottom navigation with navigation component

I want to perform a navigation just like instagram and youtube and i tried many ways how should it be implemented? by the way it should work with the Jetpack's Navigation Component what is the newest and easiest and most reliable approach? Thanks…
1
vote
0 answers

Can I add a fragment dynamically to the backstack without the xml?

I have a 2 fragments, one is my main fragment that I initialize in the main activity, and the other is one that I want to instantiate when a button is clicked on the first fragment. I am having issues adding fragment 2, but I can replace with no…
1QuickQuestion
  • 729
  • 2
  • 9
  • 25
1
vote
2 answers

Fragment not Opening Previous Fragment on Back Button

I have been struggling to implement a super simple app layout, where my MainActivity opens Fragment#1 in its onCreate method, then the Fragment#1 opens Fragment#2 when an item is clicked. As of right now, when I open Fragment#1 from my MainActivity,…
austinw
  • 594
  • 1
  • 7
  • 18
1
vote
2 answers

How to know when `navController.popBackStack()` was called?

I am popping the backstack on my nav controller on some point in my code - navController.popBackStack() The fragment that added that following fragment to the backstack needs to know exactly when that one was popped in order to trigger code…
Alon Shlider
  • 1,187
  • 1
  • 16
  • 46
1
vote
0 answers

How to add fragments to the back stack programmatically?

I have 4 fragments FragmentA, FragmentB, FragmentC and FragmentX. Once I move from FragmentX to Fragment C I want the FragmentA FragmentB added to back stack as if passed onto A,then B before. If I push back the order should be B,…