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
0 answers

What is the difference between Fragment pop back stack and removing fragment using trasaction ? Which is the best way to remove a fragment?

I was working on some issues related to memory leaks. When I was removing a fragment using a fragment transaction(fragmentManager.beginTransaction().remove(fragment).commit()), I noticed memory leaks. But when I use a pop back stack…
sandeep dhami
  • 188
  • 1
  • 10
1
vote
1 answer

How to handle onBackPressed for Android App with Bottom Navigation

I have a MainActivity with BottomNavigation and a frameLayout. The BottomNavigation can navigate to three different fragments. But when i press the back button, the checked Item on my bottom nav does not check the correct menu item. How do i solve…
1
vote
1 answer

How can I remove my Activity setContentView from the Back Stack?

There are a hundred questions regarding this on Stackoverflow, but none of them are about my specific issue. I'm starting my Activity with this code as a static function within my Activity class: fun startForResult(activity: Activity, code: Int) { …
szaske
  • 1,887
  • 22
  • 32
1
vote
2 answers

Remove specefic fragment from backstack that is not on top of backstack

Short Version: I have 5 fragments all added to a container by replace method(A -> B -> C -> D -> E), now I want to remove 3rdfragment from my backStack(C) and stay in the current page, how to do it? The problem: I have 3 fragments, FragmentA,…
feridok
  • 648
  • 7
  • 26
1
vote
1 answer

How can I pop the back stack from a FragmentActivity to the previous activity?

I have a FragmentActivity (called "QuizActivity") in which the user navigates through a series of question fragments, taking a quiz. Once they get to the end of the quiz, they transition to a fragment (still in the QuizActivity) that shows the quiz…
LarsH
  • 27,481
  • 8
  • 94
  • 152
1
vote
1 answer

Back Stack count increasing when clicked on fragment in background

I am adding the next fragment when clicked on textView in each fragment. My Flow is MainActivity => Fragment A => Fragment B => Fragment C => Fragment D But every time I click on textView in Fragment D, Fragment D gets added and back stack count…
1
vote
0 answers

How to implement proper navigation similar to YouTube's and Instagram's using Android Kotlin

I am having difficulty with implementing a proper navigation structure in my app. I want it to behave similarly to the navigation in YouTube and Instagram. The biggest problem I am having is with the backstack and fragment recreation. I'm currently…
1
vote
1 answer

Single activity multiple fragments / separate activities in a multi-step flow?

I've been developing Android for 3 years, and this is still a hard thing to decide when it comes to the similar scenario. Nowadays, I believe most of the applications has a multi-step screen / flow. For example, a booking flow. You need to proceed…
1
vote
1 answer

Android - remove specific fragment from middle of stack not working

I want to implement a dynamic fragment stack. More specificaly for example assume the following stack: A -> B -> C -> D It is possible that B will be added again after D. If that happens I want to remove B so that the result will be: A -> C -> D ->…
Anonymous
  • 4,470
  • 3
  • 36
  • 67
1
vote
4 answers

All Editexts be replace by same value after pop a Fragment

I have a strange issue, I have 2 fragment, in first fragment, I have some custom EditText, and a button to replace this by second fragment (addToBackStack = true), then, in second fragment, I try to using popBackStack() to back to first fragment,…
GianhTran
  • 3,443
  • 2
  • 22
  • 42
1
vote
1 answer

Is current Fragment destroyed in every Replace transaction without addToBackStack?

Fragment A -> Fragment B (Replace Transaction added to back stack) getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.container, fragementB).addToBackStack("tag").commit(); Fragment B -> Fragment C (Replace Transaction NOT…
1
vote
1 answer

setDisplayHomeAsUpEnabled(true) opens Options Menu

I have a fragment MyProfile (consists info about a logged user) which I want to be used by fragments Team (consists info about all team members). When I use MyProfile for Team fragment, I need up button. I read documentation guide, tried all from…
1
vote
1 answer

Navigating back from nested fragments in ViewPager

I need to display multiple set of instructions to the user. For each instruction(FragmentA) the user can navigate to another screen (FragmentA1). I have used a ViewPager that hold list of fragments. When user navigates to the first…
1
vote
1 answer

Fragment Backstack Toolbar title

Is there an efficient way to automatically set the toolbar's title when adding/replacing fragments as well as popping fragments from the backstack? I have implemented this abstract method in my BaseFragment class: abstract fun header() :…
Dale Julian
  • 1,560
  • 18
  • 35
1
vote
0 answers

Why a fragment from the backstack gets triggered when adding a new fragment

Something strange is happening..! So I have an activity with TextView in the center of the toolbar acting as toolbar title, once the activity gets launched, I commit the MainFragment or let's name it Fragment (A). Inside Fragment (A), I replace it…