When I replace a fragment, it gets destroyed. I tried to create the fragment in activity's onCreate and hold its reference in the activity and use it when I "re show" or "reopen" it by calling replace with the reference, but that did not help and the fragment got destroyed (when replaced by another fragment) and recreated. What should be the solution?
What I'm trying to achieve is something like say WhatsApp where fragments should not be destroyed when not visible, except I'm not using a sliding gesture but rather regular buttons.
Thanks.