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
2
votes
3 answers

IllegalStateException when adding Fragment from Backstack

From time to time I get the following crash report: java.lang.IllegalStateException: at androidx.fragment.app.FragmentManagerImpl.addFragment (FragmentManagerImpl.java:1916) at androidx.fragment.app.BackStackRecord.executePopOps…
2
votes
1 answer

Android remove transaction from back stack

I have 3 fragments, and I'm navigating using bottom menu (3 items), lets say I navigate this way : A -> B -> C -> B -> C when I press the back button, that's what will happen A <- B <- C <- B <- C and what I want is this A <- B <- C that's mean…
2
votes
0 answers

How to safely pop FragmentManager's back stack after the state is already saved

So, if I want to e.g. replace Fragment, I can do the following: ft.replace(R.id.frame, newFragment); if (mFragmentManager.isStateSaved()) { ft.commitAllowingStateLoss(); } else { ft.commit(); } The above code will…
Vasiliy
  • 16,221
  • 11
  • 71
  • 127
2
votes
1 answer

Android added fragment unable to show after back pressed

I have 3 fragment fragmentA, fragmentB, fragmentC that are added by default on the activity on create to keep it instance after that, I have another fragment fragmentX that to be added on the fragment container with backStack on Button click, the…
2
votes
1 answer

Android, notify backstack fragments on some change

What is the best practice to notify all the fragments that are in backstack on some change? I try to use EventBus and every Fragment subscribe to the event, then when change is happening the main activity send post event to all the subscribers. Only…
2
votes
0 answers

Do I need to remove a fragment if I pop it from the back stack?

I have looked at the solution below, and it looks strange to me: https://stackoverflow.com/a/13074955/499206 Is it really necessary to explicitly remove the fragment using a fragment transaction if I pop it from the backstack using…
2
votes
3 answers

How to remove only particular fragment from back stack?

I am working with fragment architecture i designed login page in a fragment, i want to remove the only login fragment from back stack after user login successful and open another fragment, please help me.
Vikas
  • 59
  • 3
  • 8
2
votes
0 answers

How to handle Back Button in nested fragments of Viewpager

According to I have an Activity which contains ViewPager which loads three fragments: RootA RootB RootC RootA loads another fragment which named as FragA. RootB loads another fragment which named as FragB. RootC loads another fragment which named…
2
votes
2 answers

Fragment does not pop out from backstack?

I have three fragment A, B and C This is the path : A -> B -> C : A go to B and B go to C When I go back from the fragment C , I want to go to the fragment A. A <- C : C go back to the root fragment A A <- B : B go back to the root fragment A…
Imene Noomene
  • 3,035
  • 5
  • 18
  • 34
2
votes
1 answer

Fragment back stack clearing Issue

I am working with fragments and the navigation flow like Fragment A -> Fragment B -> Fragment C -> Fragment D Form fragment D I need to navigate to fragment A by clearing back stack but the problem is in onCreateView() method of fragment C I am…
2
votes
5 answers

Returning to MainActivity's fragment after return back from another Activity?

I have two Activities: MainActivity and OtherActivity. A fragment in MainActivity launches the OtherActivity, but when I press the back button at the top, it returns me to the MainActivity instead of the fragment that launched the OtherActivity. The…
2
votes
1 answer

Fragment oriented architecture and the back stack

I am learning how to implement a "single activity - multiple fragments" architecture. It is widespread approach nowadays as I understand and you can find a lot of articles on this topic. For example this one…
2
votes
2 answers

Prevent last Fragment from being removed from backstack

I am currently writing a drawer layout as my main layout, with an embedded FrameLayout that I will be using to hold each “page” when an item on the drawer is clicked on. When the app first starts, an initial fragment will be show. Other fragments…
2
votes
4 answers

Fragment,DialogFragment Issue

I am calling dialog fragment from FragmentA and returning some values to fragmentA. Now issue is whenever i go to another fragmentB from same fragmentA and return to it my dialog fragment values get cleared. when i click on consultant doctor…
2
votes
0 answers

Handling multiple transitions between activity and fragments in android

I have 2 fragments in an activity A, Frg1 and Frg2. Frg1 requires an object o1 as input and Frg2 requires o2 as input. There is another activity B. So i start from Frg1 where I already have o1. So i populate Frg1 then i move to Frg2 where I get o2…