I am very confused between these functions and their purposes. What I have observed that using replace()
replaces the existing fragment with a new one. We can use addToBackStack(null)
to put that fragment in back stack so we can go back to the previously shown fragment. Now when a fragment is added (or replaced) - onAttach()
-> onCreate()
etc.... methods of the fragment are called in order.
Now when we call remove()
on the fragment from our activity, which functions of the fragment are called and in which order?
What does attach()
and detach()
do? Does detach()
remove the fragment? And when these two attach()
and detach()
are used, which functions of the fragment are called and in which order??
Also, what happens on popBackStack()
?? I mean which functions are called when we use popBackStack()
on the fragment from our activity??
And when does onDestroy() called??
Thank you.