Introduce Android Development and its Various Lifecycle
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 the instagram there will be main view that have 5 main navigations. That is all view is attach at the activity and fragment (we talk about it later).
Even we understand about it at the simple explanation, we have to fully and deeply understand the lifecycle of activity in Android because with the understand of the lifecycle we know when to implement every state of the lifecycle in the proper way.
Alright, let’s learn and run through it together.
The source of image can you see from this :
https://developer.android.com/guide/components/images/activity_lifecycle.png
The activity lifecycle is stand for:
- onCreate()
The state of onCreate will be operate for the first time when we open the app. This state must be implemented no mater what.
2. onStart()
This callback will be invoke when the activity state enters the start state. This state will operate very fast after the onCreate state implemented and this activity not stay for a long time because after it finished it will be enter for the new state.
3. onResume()
After the activity finished the onStart state the system will enters the Resume state.
4. onPause()
This state will be call when you leaving the current actitivity or this state will be call when the activity not on foreground of the app. For example if you in activity A then you move to activity B then the activity A will be in onPause() state.
5. onStop()
This state will be call when the activity to longer visible to the user. This state also will be executed when the new activity take over the entire screen
6. onDestroy()
This is the last step, it will be called when the activity finishing because movement finish() action or the system is destroying the activity when configuration the device