Android Activity Lifecycle

by Diana Wanjuhi, Moringa School Student

If you are new to Android Programming, you may have heard the term Activity tossed around. Now, before you freak out since there was nothing in your Object Oriented Programming tutorial about Activities, hear me out.

Ever notice how every time you start up an application, say YouTube:

  1. There is some sort of Welcome Screen
  2. There is a variety of actions you can take: search for videos, swipe et al
  3. You can temporarily exit the app and return to it
  4. On doing so, you can resume your video where you left off
  5. On closing the app, that particular session is over
  6. Each of these actions has an associated view or screen

All this is a series of Activities within the application. Think of Activities as all the different things that your user can do within your app.

Here are two flowcharts showing all the important states of an activity:

State diagram for an Android Activity Lifecycle.

This is a simplified version:

You need to get this right as a way to make sure your user:

-can switch between your app and other apps

-can save their progress

-can do lots of other cool things with your app

To read more, visit:

These are great resources for any Android developer.

It might also be helpful to understand the MVC model for implementing user interfaces.

Live long and prosper.

PS: Pen and Paper will always be your most powerful weapon when thinking through the logic of your app.