This is a follow up question to this question:
Dilemma: when to use Fragments vs Activities:
When I create an Android app, I create a single (or very few) activity and leave most of the logic to fragments. The activities in my case are mainly intended to be a container for fragments which are replaced with a FragmentTransaction
.
Every time I'm searching for a formal explanation with advantages of this method, I always see some metaphors or incomplete answers, like in the question I linked above.
I was recently told that when a user replace a fragment, the previous Fragment's onDestoryView
is called, which helps saving space and that this is actually the main reason for using fragments over activities. Is that correct? Are there other reasons which are maybe even more significant?
Please note that I'm looking for a more technical explanation of the advantages of this method rather than knowing when I should use it. I don't want an explanation of when is it a good idea to use multiple activities or multiple fragments, but my question is more of: "considering I'm already using this method, what are my advantages?". Does it save space? Is it lighter to switch a fragment than an Activity? Something else?