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

Fragment still visible after popBackStackImmediate and replace

I have fragmentA on my backstack and fragmentB on the screen. I want to replace fragmentB with fragmentC so that when user pressed back, we go back to fragmentA. This is how I am replacing fragmentB with fragmentC final FragmentTransaction…
1
vote
3 answers

In fragment I want to click back how to show alert dialog

I am using navigation menu in an Activity. When I click menu, it goes to particular fragment that time I give addtobackstack(null). I want to fix these 2 issues: I want to show do you want to exit app through a popup In the back fragment Assume…
kalai vani
  • 289
  • 2
  • 4
  • 21
1
vote
7 answers

Back Button pressed handler

I'm working on an app that need Navigation Drawer. This app has 1 MainActivity and about 10 fragments on it. When I click the Navigation Drawer icon in MainActivity it will show the 10 fragments so I can select each of them. I choose fragment A,…
1
vote
1 answer

NullPointerException when popBackStackImmediate()

I have problem with fragment's backStack. Firstly, my structure is: I have activity with fragmentManager, new fragments added with method add() and with adding to back stack. So, when I have at list 2 fragments in backstack and when I have…
1
vote
2 answers

Loading a Fragment from an Activity to another Activity which is already in backstack

I have an activity(let's call it Home Activity) with bottom navigation view where I replace all of my fragments. In Home Activity I have loaded a fragment which has a search icon. That search icon redirects to an activity that is Search…
1
vote
0 answers

Fragment Back Stack onSaveInstanceState Behavior

I'm playing around with the fragment back stack and I noticed some odd behavior. I wrote a simple test program consisting of a single activity with a fragment container. I have a two buttons, one which replaces the current fragment with a new…
SilentByte
  • 1,098
  • 1
  • 10
  • 21
1
vote
1 answer

Hardware BACK Btn not working first time

I have a number of fragments which have been added (not replaced) one on top of the other. And they have also been added to the back stack expect the first one. Fragment A -> Fragment B -> Fragment C Hardware Back Btn press works fine when I am on…
1
vote
2 answers

popBackStackImmediate not showing fragment when the current fragment transaction is not added in the backstack

Popbackstack is working fine when all the fragments in the sequence are added in the backstack but isnt working when one of the transactions is not added in the backstack. Here is my navigation: 1.Replace fragment to load home fragment. This…
1
vote
1 answer

Fragment showing on back button press, even though not added to backstack

I have an application where the MainActiviy works with a bottom navigation which switches between full screen fragments. I've learnt to control the back button navigation by ensuring I add each fragment to the backstack when created.…
1
vote
2 answers

Back button not working when adding fragment to backstack

I've been trying to figure this one out. I'll start by saying that there are many StackOverflow solutions but most say to hookup the onBackPressed() myself, which does work, but I don't understand why I don't get that behavior for free with the…
Alon
  • 601
  • 9
  • 19
1
vote
1 answer

PopBackStack previous last fragment and check which fragment it is

I got a few fragments in MainActivity which can be selected from Navigation Drawer. Now, whenever users press a profile button, it will jumps to UserProfile Fragment. If home button is pressed, it will pop back the last fragment. Since I've assigned…
1
vote
4 answers

previous fragment taking too much time to load on back press

I have an app that is mainly based on fragments. Each fragment involves it's own json parsing and image loading from json.Also to be noted that I have called addToBackStack(null) on ech fragment when it's getting replaced. As I switch between the…
Nishan Khadka
  • 385
  • 1
  • 2
  • 14
1
vote
3 answers

Clear fragment backstack without invoking onCreateView of popped fragments

My app has 3 UI levels, each level has its own fragment, A -> B -> C. I wish to optionally allow my app user to navigate straight to the top level fragment i.e. from C -> A without invoking B. i.e., I still want to allow the user to go from C->B…
user90766
  • 329
  • 1
  • 4
  • 17
1
vote
3 answers

Maintain fragments-backstack of previous Activity

I have 2 Activites A & B, In Activity A I managed fragment back stack but in one case as like below: I have 4 fragments in Activity going from fragment 1 to 2 to 3 to 4 then from 4th fragment I'm going to Activity B now what i want is on press of…
Rajesh Panchal
  • 1,140
  • 3
  • 20
  • 39
1
vote
2 answers

Fragments navigation

I need to create navigation of fragments like in Gmail app. It's like: we have one main fragment A, we can open another fragment (B,C,D...) from navigation drawer, and when we open new fragment, it`s open on top of main fragment, and when press back…