Different lifecycle variants of Fragment

Fragment is no longer stranger to anyone who consider himself competent in Android Development. But I notice there are still some confused over it’s variants of its live-cycle. Hopefully this blog clarifies them.

In case you’re still wonder Activity or Fragment, refer to this blog.

Understand these different variants would also be helpful for QA testing, to ensure all flows are intact (this is usually a source of bugs, when developer focus on fixing one flow and hurt the other one).

TL;DR;

Let me start off with a summary table for them. I break them into showing and hiding the Fragment, and the

I use showing and hiding term as it represent the creating the entire fragment, creating just the view, resurfacing the view and it’s corresponding destroying, destroying view and put to background action.

If any of the flow above you are not clear about, feel free to read on the below section.

--

--