"Back stack" is a stack in which activities within an Android task are arranged. Android task is a collection of activities that users interact with when performing a certain job. Through this process activities are placed on the stack, in the order in which each activity is opened. Activities can be accessed later in reverse order by pressing the "back" button.
Questions tagged [back-stack]
658 questions
11
votes
1 answer
Recreating backstack with Android Navigation Architecture Component
I am trying to implement navigation to specific Detail pages of my app using PendingIntent from a notification, however I am having problems recreating the backstack from the Detail page all the way back to the start destination.
I made a sample app…

limdale
- 201
- 1
- 8
11
votes
5 answers
Going from 3rd to 1st fragment in the backstack: Android
I have a sequence of event via which i have added three fragments to the backstack, one by one. Each of these fragments covers the full screen of the activity.
I have stored the is returned from the commit of Frag1.
Now in Frag3, based on a…

Sunny
- 7,444
- 22
- 63
- 104
11
votes
1 answer
addToBackStack doesn't work, closes the activity instead of popping back fragments
I have a probleam and I can't find a solution anywhere.
My app doesn't return to previous fragment when I press the back button, instead closes the activity.
I have an activity that displays 4 fragment: [1],[2],[3],[4]. I can switch between the…

JoP
- 555
- 8
- 18
10
votes
5 answers
How to preserve current back stack (or task) when notification is clicked?
In my application, I create a notification which starts Details Activity. I want to add this activity to top of current task (or back stack). For example I expect application task (back stack) to behave like this:
but I get this:
I have not used…

h.nodehi
- 1,036
- 1
- 17
- 32
10
votes
1 answer
How to persist fragment data after backstack transactions?
I've got an activity, containing fragment 'list', which upon clicking on one of its items will replace itself to a 'content' fragment. When the user uses the back button, he's brought to the 'list' fragment again.
The problem is that the fragment is…

Benoit Duffez
- 11,839
- 12
- 77
- 125
10
votes
3 answers
How to handle back button using view pager?
I am having two fragments Frag A and Frag B which are rendered using view pager .
If user has swiped from A to B then presses back button(when in B) then user should go to A instead of coming out of view pager . How can we achieve this ?
Adding…

Preethi
- 2,112
- 7
- 38
- 54
10
votes
6 answers
Use backstack with ViewPager
I am using a ViewPager to implement swiping in my android app. However, I would like the previous fragment to be shown when the user uses the back button instead of ending the activity. Is there any way to do that?
Thanks
Sebastian

Sebastian
- 103
- 1
- 1
- 7
10
votes
2 answers
How to remove singleTask activity with taskAffinity from recent tasks when it is finished?
Let assume we have two activities.
A - main activity, that is "home launcher enabled" (proper intent filters etc.)
B - task root activity with singleTask specification (there can be only one instance of this activity) and with custom taskAffinity…

Michael P
- 670
- 7
- 23
9
votes
2 answers
Android Fragment null object mNextAnim Internal Crash
Users of the app I am working on have a crashing issue. This is the stack trace I get from the console.
java.lang.NullPointerException: Attempt to write to field 'int android.support.v4.app.Fragment.mNextAnim' on a null object reference
at…

sethprogrammer
- 99
- 1
- 1
- 3
9
votes
1 answer
Clear back stack when application object gets killed by the system
I have an application with a lot of activities. Among them there is InitialActivity which loads the core data. It's a launcher activity and none of the next activities can live without the loaded data.
So I launch the app, the InitialActivity is…

Andrew
- 490
- 3
- 18
9
votes
1 answer
after configuration change fragment from backstack is now sharing the FrameLayout?
Problems with app:
When orientation changes the app is experiencing these problems:
Both FragmentA and FragmentC now occupy the FrameLayout container.
What works: Everything works as I want it to...prior to rotating the screen.
Activity…

ross studtman
- 936
- 1
- 8
- 22
8
votes
2 answers
Android onConfigurationChanged: how to save and restore fragment back stack?
I have an activity with a dual pane: a list of menu items on the left (fragment M) and details of the currently selected item on the right (fragment D).
When the user selects an item in fragment D, fragment D gets replaced with another fragment…

Luke
- 290
- 4
- 11
8
votes
2 answers
How to add BackStackEntry to BackStack if not exists
I've added custom keyboard to my Fragment and now I want to implement closing keyboard when on back pressed.
class CustomKeyboard
{
public void init(Context context) {
//...
FragmentManager fragmentManager = ((Activity)…

Yuliia Ashomok
- 8,336
- 2
- 60
- 69
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…

Brian P Grissom
- 513
- 4
- 10
8
votes
4 answers
Pressing back does not return to previous fragment
I have a problem with adding the fragment transactions to the back stack. I have a Main activity in which I populate my layout with a Menu Fragment:
public class MainActivity extends ActionBarActivity{
@Override
protected void onCreate(Bundle…

JamMaster
- 1,446
- 1
- 14
- 24