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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答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.