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

Recyleview inside fragment is empty when comming back from other fragment

I'm working on an app with fragments (an app with only activity but multiple fragments). The problem I have is that when I go to a fragment and go back (system back button) to the initial fragment, it's RecycleView is now empty. The weird thing…
3
votes
3 answers

Handle OnBackPress from Fragment

I have 3 fragments Fragment1, Fragment2 and Fragment3 and navigation is like Fragment1->Fragment2->Fragment3 But on back press From Fragment3 go back to Fragment2 after completing some task like from Fragment2. And from Fragment1 finish this…
Vineeth Mohan
  • 2,584
  • 4
  • 17
  • 31
3
votes
1 answer

Backstack in Fragment Android

I am working in an application where i am calling Fragment2 from Fragment1, when I am pressing default back button in Fragment2 it is taking me to Fragment1 but when I am pressing any other button and calling getActivity.finish() it is closing my…
Usman Khan
  • 3,739
  • 6
  • 41
  • 89
3
votes
3 answers

How to know if any fragment is active or visible?

I have three fragments A,B and c in one activity, activity has a toolbar with test view title. Now as I navigate from fragment to fragment I want to change the text of text view depending on which fragment is shown. For this in fragment B and C I am…
Sid
  • 2,792
  • 9
  • 55
  • 111
3
votes
2 answers

Fragment count not working as expected with ProGuard

I have a function on my AppCompatActivity where it determines the number of fragments in the fragment list - below is the code : if (getSupportFragmentManager().getBackStackEntryCount() > 0) { List fragmentList =…
3
votes
0 answers

Fragment.setNextTransition(int, int) throws NullPointerException

I use support fragments for my app (with setRetainInstance(true) in onCreate()). Some times the app throw NullPointerException: Fatal Exception: java.lang.RuntimeException: Unable to start activity…
3
votes
1 answer

Initial Fragment not rendered when popping entire FragmentManager BackStack

Actual problem / TL;DR: Except when using one way I consider a hack, I can't pop the activity's entire backstack to return to my initial state with a single fragment added during onCreate(). The Fragment is present in the Activity State Manager…
Oceantume
  • 33
  • 3
3
votes
0 answers

android - fragment backstack with bottomnavigationview onSaveInstanceState does not call properly

I have a problem with my fragment onSaveInstanceState. I searched on stackoverflow and other sites, I could not get exactly same problem with my issue. I have a bottom navigation view ( which is not android support library bottom navigation view if…
3
votes
0 answers

android FragmentTransaction.remove not working

I have a Fragment stack, which fragments are added to (not replaced). The problem is, because of memory issues, I don't want to have more than a specific amount of fragments in the stack. Suppose I have added fragments A, B, C, D to the stack. Now…
Kayhan Asghari
  • 2,817
  • 1
  • 28
  • 47
3
votes
3 answers

How to listen when a fragment is on the screen

What I need is exactly an onResume method (as it works for activities) for a specific fragment. I'm adding the fragment (let's say fragment A) to the back stack, and opening another fragment (fragment B) (again adding to back stack) from fragment A.…
iamkaan
  • 1,495
  • 2
  • 23
  • 43
3
votes
3 answers

FragmentTransaction::replace() with or without addToBackStack()

Having a flow to add fragment and later replace() fragment. All fragment are dynamically added, but not all call addToBackStack(). getSupportFragmentManager().beginTransaction() .add(R.id.frgment_holder, frgmtA, frgmtA.NAME) .commit(); and…
lannyf
  • 9,865
  • 12
  • 70
  • 152
3
votes
3 answers

How to remove Fragments from backstack

There is an Activity with 5 fragments (wizard). StartFrag -(start)-> Frag1 -(next)-> Frag2 -(next)-> SubmitFrag -(submit)-> SuccessFrag. After Taping SubmitMore button on Success fragment, I want to remove Frag1, Frag2 and SubmitFrag from…
hhs
  • 716
  • 1
  • 6
  • 22
3
votes
3 answers

Android Backstack with Nested/Child Fragments

I've got a problem with the way backstack of nested Fragments and would be most grateful for any help that is offered. I have Fragment A and Fragment B. Fragment A contains an other Fragment (ButtonFragment). In the onCreate of the Activity I load…
2
votes
0 answers

Fragment inside a fragment not persisted when using multiple back stack

So, I use this approach to support multiple back stack for my app, google sample code. This code should make bottom navigation component persist the fragment and all of the content(scroll state, etc) inside it. So the problem is when I have fragment…
drax
  • 23
  • 2
2
votes
0 answers

Retain Backstack for Bottom Navigation Bar Android Studio (Java)

as per my name I am new to this, and need help. This is a simple app with one main activity that has a bottom navigation bar used to navigate to multiple different fragments. In the main activity, clicking on R.id.nav_first/second in the navigation…