DEV Community

Cover image for Explain Activity Lifecycle Like I'm Five

Posted on


Explain Activity Lifecycle Like I'm Five

Top comments (6)

weswedding profile image
Weston Wedding • Edited

I feel like more info is needed here. What's tripping you up?
The official docs about Activity Lifecycle are so good already!

Android Activity Lifecycle Flowchart

filipjelic profile image

No, I understand it, but as the tag says #explainlikeimfive. It's all about explaining something to people who have little or no experience.

auct profile image

explainlikeimfive is great for non-techy guys, but for it guys nothing is better than actual manual.

chrisvasqm profile image
Christian Vasquez • Edited

Challenge Accepted

(I'll try to come back later when I have some free time to write down my ideas).

enzoftware profile image
Enzo Lizama Paredes

An activity is a single screen in android, its like a window in a desktop app. And depends on whats happening with the app and with the user interaction, it can be in one of several states : that the life-cycle.
So, for know what do each method does the best resource is the official docs, but I will try to make a summary as short as possible:

onCreate(): This is called when the activity is initialized, you need implement this method in order to do any initialization specific to your activity.

onStart(): The activity start to be visible for the first time to the user.Once this callback finishes, the onResume() methods will be called.

onResume(): Into this state , it begins interact with the user. The activity continue in this state till something happen to take focus from the app or Activity (such as a incoming call). When this happen the onPause() method is called.

onPause(): This method is used to pause operations that should not happen when the Activity is in paused state. A call to this method indicates that the user is leaving the app.When the user returns to the app, the onResume() method will be called.

onStop(): his method is called when the Activity is no longer visible in the app.In this state, the system either calls the onRestart() to bring back interactivity with Activity. Or it calls the onDestroy() method to destroy the Activity.

OnDestroy(): This gets called before the Activity is destroyed. The system calls this method when a user terminates the Activity, or because the system is temporarily destroying the process that contains the Activity to save space. Be sure to free up any resources your Activity has created in this method, or else your app will have a memory leak.

OnRestart(): This gets called when an Activity restarts after it had been stopped.

Check the classic resources too :

I like this image over the classic one, i believe its more for a #explainlikeimfive topic.

Android LifeCycle

filipjelic profile image
Filip • Edited

If I were five, I would look you like this


🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.