An activity is one of the key components of an Android application. It provides the user with an interface to interact with. Imagine if your smartphone screen was pitch black, you won’t be able to see any button or features of the app. Hence, you can’t interact with it.
In simple words, activity is anything that you do on your Android device. There are four states in which an activity can be during its lifetime.
As the name suggests, this state means that the activity is up running and active. It is visible to the user to interact with. An activity in the active state is always on the top of the activity stack. What’s an activity stack? It is a stack that stores the different activities as they occur. For example, you started playing a song in the music player. This will PUSH the music player on the empty stack, so now it is on the TOP of the stack. Now, assume that you went on to check your Instagram feed with the music playing in the background. The music player now gets PUSHed down in the stack and Instagram gets placed on TOP because it’s currently active and has the highest priority.
In this state, the user can see the activity but can’t interact with it. An example of this is when you’re chatting on Whatsapp and you pull down the notification panel from above. In this situation, Whatsapp is paused, you can see it partially being transparent.
When you press the home button on your smartphone, the current activity isn’t destroyed, it justs goes invisible, waiting in the background. If you restart the activity, it will retain its previous state.
Here, the activity is destroyed i.e, removed from the activity stack. If you restart the activity, it will not retain its previous state. It begins refreshed.
If there are any doubts let me know in the comments below! or shoot me a mail at email@example.com