Table of contents
No headings in the article.
What is the activity in Android?
The simple way to describe it is the activity in Android Development is the User Interface to manage the view to the user, when you open Instagram there will be the main view that has 5 main navigations. That is all view is attached at the activity and fragment (we talk about it later).
Even if we understand it in a simple explanation, we have to fully and deeply understand the lifecycle of the activity in Android because, with the understanding of the lifecycle, we know when to implement every stage of the lifecycle properly.
Alright, let's learn and run through it together
The activity lifecycle is stand for:
onCreate()
The state of onCreate will be operating for the first time when we open the app. This state must be implemented no matter what.
onStart()
This callback will be invoked when the activity state enters the start state. This state will operate very fast after the onCreate state is implemented and this activity does not stay for a long time because after it is finished it will be entered for the new state.
onResume()
After the activity finished the onStart state the system will enter the resume state.
onPause()
This state will be called when you leave the current activity or this state will be called when the activity is not in the foreground of the app. For example, if you are in activity A then you move to activity B then activity A will be in the onPause() state.
onStop
This state will be called when the activity is no longer visible to the user. This state also will be executed when the actors take over the entire screen.
onDestroy()
This is the last step, it will be called when the activity finishes because action finish() in the activity or the system is destroying the activity when configuring the position device.