Activity is the first building block of an Android App. If you are writing an app which will interact with user in some way then you will need an activity. Activity handles the UI of an Android App. In our blog today we will go through some of the theoretical concepts behind the activities
An activity has different stages in its lifecycle. The following is the list of the stages
-
Created – The activity has been created but is not visible
Started – The activity is in the process of being displayed and is only partially visible
Resumed – The activity is fully visible and can be interacted with
Paused – The activity is only partially visible
Stopped – The activity is not visible and may be either restarted or destroyed
Destroyed – The activity is no longer in memory
Each of these states are reached via method calls and we summarize them as follows
onCreate ()– It takes the activity to created state. It is the first method to be called
onStart() – It is called to get to the started state. It follows onCreate.
onResume() – This calls the Resume state which is the most important of the states. It is called after onStart(). The activity stays in this state the longest.
onPause() – It gets activity to the Paused state. It gets called on the Resumed state.
onStop() – It takes the activity to Stop state
onRestart() – It takes the activity from stop state to starting state.
onDestroy() – It takes the activity to destroyed state
Attributes – The above methods have the following attributes
-
They are called before the state is entered
Can be overridden
Must call through Super
To get a detail description check out our video here
Hope you have enjoyed our blog today.