Activity Methods | Description |
---|---|
OnCreate() | This method is called when activity is created. It is used to initialize the activity. It takes a 'Bundle' parameter which is used for storing and passing state information and objects between activities. |
OnStart() | This method is called when activity becomes visible to the user. It is called by the system after OnCreate() method is finished. |
OnResume() | This method is called when activity will start interacting with the user. It is used to initialize fields, register listeners, bind to services etc. |
OnPause() | This method is called when current activity is being paused and the previous activity is being resumed. Activity is not destroyed and not visible to the user. It is used to release resources or save application data. |
OnStop() | This method is called when activity is no longer visible to the user. |
OnRestart() | This method is called after your activity has stopped and restarting. |
OnDestroy() | This method is called before the activity is destroyed. |
Activity State | Description |
---|---|
Running | This state defines that the activity is visible and interacts with the user. |
Paused | This state defines that the activity is still visible but partially hidden and the instance is running but might be killed by the system. |
Stopped | This state defines that the activity is not visible and the instance is running but might be killed by the system. |
Killed | This state defines that the activity has been terminated by the system call to its finish() method. |