← Playground
Android
2 minutes

The lifecycle, in the right order

Everyone can recite onCreate… then it gets fuzzy. Put the callbacks in the order they actually fire — then find out what happens when the user rotates the screen or hits Home. Toggle between Activity and Fragment.
0 / 6

Tap the callbacks in the order they fire, from birth to foreground.

onDestroy()
onStart()
onCreate()
onStop()
onPause()
onResume()
The one-line takeaway

Lifecycle callbacks are symmetric: everything you set up on the way up (create → start → resume) you tear down in reverse on the way down (pause → stop → destroy). Do heavy work as late as possible and release it as early as possible.


Why the Fragment one trips people up

A Fragment has two lifecycles that don't line up: the fragment itself, and its view. On a back stack the view can be destroyed (onDestroyView) and rebuilt (onCreateView) while the fragment instance lives on. That's why you set up UI in onViewCreated and observe LiveData/Flow with viewLifecycleOwner — never this — or you'll leak an observer onto a dead view.

Enjoyed this?

I build Android & cross-platform apps freelance and love turning gotchas into "oh, that's all it is" moments.