I'm trying to understand An Activity full life-cycle.
So I have searched on Google and found lots of tutorials regarding activity life-cycle, but in all tutorials I have not found these methods in life-cycle diagram:
1. OnContentChanged()
2. OnPostCreate()
3. OnPostResume()
4. OnWindowfocusChanged()
5. OnuserLeaveHint()
6. OnUserInteraction()
7. OnDetachedFromWindow()
I would like to known why these method's are not included in activity life-cycle diagram on android docs.
One more question:
When an activity is created for the fist time then system calls the OnContentChanged()
method as the first method and last call by system is the OnDetachedFromWindow()
method when an activity is killed, but android docs says entire lifetime of an Activity happens between OnCreate()
and OnDestroy()
?
Activity Lifecycle: Activity is one of the building blocks of Android OS. In simple words Activity is a screen that user interact with. Every Activity in android has lifecycle like created, started, resumed, paused, stopped or destroyed. These different states are known as Activity Lifecycle.
The Activity lifecycle is especially important because whenever an activity leaves the screen, the activity can be destroyed. When an activity is destroyed, when the user returns to the activity, the activity will be re-created and the lifecycle methods will be called again.
Hence, all in all there are four states of an Activity(App) in Android namely, Active , Paused , Stopped and Destroyed .
The activity lifecycle is the set of states an activity can be in during its entire lifetime, from the time it's created to when it's destroyed and the system reclaims its resources. As the user interacts with your app and other apps on the device, activities move into different states.
Check out the Documentation for Activity All of these are in there, and many of them contain more detail than what I've listed here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With