Android Activity Lifecycle
Android Activity Lifecycle:- When an application is run, it has a life cycle.When create a Activity for a application that perform a some method that call a callbacks. When a activity call in a android application then there will be some methods call which is as follows:
1. onCreare()
2.onStart()
3. onResume()
4. onPause()
5. onStop()
6. onDestroy()
1. onCreate()-
The onCreate() method is the very first method of the Activity life cycle. The onCreate() method is also called automatically when the activity is run. The design key in the original file is set in this method by the setContentView() method. As soon as the concrete method is called, we do the task of our activity there.
2. onStart():-
When the onStart() method is called, the UI we have created in the first appears on the Activity's screen.
3. onResume():-
This method is called when the user interacts with the activity. This means the activity is fully loaded. Where user move then other activity.
4. onPause():-
When user switch from current activity to another activity, the previous activity goes to pause state and when come again this activity then its start from onResume method.
5. onStop():- When user switch from current app to other app and its take longer time and other app require a memory then background app goes into onStop(). When user come again into onStop() state app then it's start from onCreate() method call.
If application is navigate to other activity then call the onRestart() method then user come into foreground then app start from onStart() method.
6. onDestroy():-
When user out from the application from and its remove from the background then application is currently goes into onDestry() method.
In this state, this method is required because if user require any service or background process or any other process that stop before application is destroy.
0 Comments
Hello Friends, Please comment and share and do not write spam messages