Today I am going to take a one of the most important lesson in the android application development. This is the first thing we need to know before develop a application. It is "how to handle the activity life cycle". Check this official diagram and i will explain the which method call in each situation.
There are 7 main methods in the activity life cycle
1.onCreate
2.onStart
3.onResume.
4.onPause
5.onStop
6.onDestroy.
7.onRestart
If we start any android application these method will execute in the different condition of the app. These are the scenarios which are these methods are executed.
Open a Application.
1.onCreate.
2.onStart.
3.onResume.
When Press Home Button activity go to background. (If call came while using the app, current app status changed to these status)
1.onPause
2.onStop
Load application again from recent application list.
1.onRestart.
2.onStart.
3.onResume.
Move to another activity. current activity state changed to
1.onPause
2.onStop
Finish the application
1.onPause
2.onStop
3.onDestroy
When Dialog open
1.onPause
When dialog close
1.onResume.
එල
ReplyDelete