6

Is that possible to check if Fragment was restored from a backstack? For example, if I had one, then replaced by another and back to previous by tapping "back" android button?

Eugene
  • 59,186
  • 91
  • 226
  • 333
  • There is one solution here http://stackoverflow.com/a/7919782/543073 However if you don't want to use addOnBackStackChangedListener, then it seems you are out of luck... check my question here http://stackoverflow.com/q/7919681/543073 – dvd Apr 20 '12 at 18:26
  • I've been looking and I think this can help you: [Link][1] [1]: http://stackoverflow.com/a/12934711/1657161 – andrehsouza Mar 26 '13 at 15:45

1 Answers1

-1

You need to have your own backstack and keep track of it.

Look at this: http://adblogcat.com/fragment-transition-animations-while-hiding-the-previous-fragment/

The code holds its own stack of fragments and hides them instead of removing them, giving it the same effect as replace (with backstack) except it doesn't recreate the fragment every time so the state of the fragment is always intact.

However, this code has a memory leak and I have to update it with the latest where the fragments don't persist. Hope this helps.

Juan Acevedo
  • 1,768
  • 2
  • 20
  • 39