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

TabLayout ViewPager Not Loading When Using Backstack

I'm using a TabLayout in one of my fragments with a viewPager to switch between two fragments below the tabs. When I click the FAB inside one of the lower fragments, I load a new fragment (for input). However- when I press the BACK button, the…
7
votes
1 answer

Why does oncreateview of the current fragment gets called on pressing the back button?

I am trying to retrieve the fragment from the backstack. It is getting retrieved but the issue is that on pressing the back button the oncreate view and subsequent lifecyce methods of current fragment is also getting called. Here's my code to put…
7
votes
2 answers

Android Fragment not added to Back Stack

I am doing a NavigationDrawer based application. I have an hierarchy like given below NavigationDrawer --> RootFragment(Not added to back Stack) --> Detail Fragment (Added to Back Stack) Now, I am trying to show a message to user when he tries…
Zach
  • 9,989
  • 19
  • 70
  • 107
7
votes
2 answers

Prevent The Same Fragment From Stacking More Than Once ( addToBackStack)

I have an Activity with three Fragments lets call them A, B and C. Fragment A is called in the Activity onCreate(). FragmentA fragA = new FragmentA(); FragmentTransaction transaction =…
7
votes
3 answers

Back navigation with Fragments / Toolbar

I'm scratching my head with this one now.... I have an ActionBarActivity that loads an initial Fragment - the original menu is inflated within the activity. Now, I have a navigation bar that, when an item is selected, loads a different fragment and…
6
votes
2 answers

Fragment backstack building with NavDeepLinkBuilder

I have a single activity app, with three fragments, A, B, C. In the normal app flow, fragments are opened in sequence: A->B->C I have a foreground service with a notification that when clicked, should open fragment C. I use Navigation Architecture…
6
votes
0 answers

Avoid IllegalStateException when doing popBackStackImmediate during onResume in fragment

I have a single Activity with fragments and two simple methods inside the activity for managing fragments: pushFragmentImmediate() and popFragmentImmediate(). public void pushFragmentImmediate(Fragment fragment) { FragmentTransaction transaction…
6
votes
3 answers

Android - Back button and fragment backstack not working

I'm developing a simple fragment-based application with a singe FragmentActivity. Each 'screen' of the application is contained in a fragment and all fragments are added to the container layout at application startup. // Set up fragments in Main…
wilblack
  • 1,077
  • 10
  • 12
5
votes
0 answers

Fragment Backstack after Process Death

As I observed it seems that the fragment backstack is not retained after process death. So if I kill my app by putting it to background and call am kill it does not recreate the fragment backstack if i take the app to foreground again. This…
tscheppe
  • 588
  • 5
  • 18
5
votes
1 answer

Android navigation component back stack

i created a nav graph with fragments fragA->fragB->fragC-fragD->fragE->fragF->fragG. From some push notification user must directly go to fragG with findNavController().navigate(R.id.fragG), and when user tap back button he must go to fragF, but now…
5
votes
2 answers

fragmentManager.getBackStackEntryCount() does not decrease when removing fragment from manager

The correct behavior I'd like to have is: Fragment A -> Fragment B -> Fragment C -> Fragment A What I currently do: When I want to go back from B to A, I use popBackStack() still here everything goes well. When I want to go from B to C I remove B…
5
votes
2 answers

Fragment is not visible after popbackstack

I add fragment (home fragment) in Activity.onCreate(), without adding it to backstack, I do it using FragmentTransaction.replace(). After that i add every next fragment using FragmentTransaction.replace() and adding it to backstack. I have a…
5
votes
0 answers

Save state of fragments in backstack

My problem is generally described in this question: Once for all, how to correctly save instance state of Fragments in back stack? But i can't understand how the accepted answer is related to it. To keep it short: There are 2 fragments A and B. I…
5
votes
1 answer

putFragment() - Fragment x is not currently in the FragmentManager

The above title has been asked a lot, but answers seem closely tied to FragmentStatePagerAdapter which has nothing to do with my problem. I'm using the method putFragment(Bundle, String, Fragment) directly. The Android Documentation for…
Graeme
  • 25,714
  • 24
  • 124
  • 186
4
votes
1 answer

Navigation Component NavDeepLinkBuilder back stack

I've met a problem with the back stack while starting the app from a deep link (via notification). The general idea is that I have 3 fragments (A, B, C). The A screen works as splash screen, so I've put a popUpTo and popUpToInclusive to the action,…
1
2
3
23 24