An activity represents a single screen with user interface(UI) i.e.,a window with which you interact with your android phone.
It is a pre-defined class in Android and every android application which has a UI must inherit it to create a window.Using activity you can place all your UI components or widgets in a single screen.
Life cycle of an activity::
There are total 7 life-cycle methods that a activity can go through. They are:
onCreate(): This method is called when the activity is first created.
onStart(): This method is called when the activity is visible to user.
onResume: This method is called when the user starts interacting with the activity.
onPause(): This method is called when the current activity is not visible to user i.e. a new activity has come to foreground and the current activity is sent to pause mode. The paused activity is unable to receive any input from the user and does not execute any code.
onStop(): This method is called when the activity is no longer to visible to user.
onRestart(): This method is called when the activity restarts after stopping it.
onDestroy(): This method is called before the activity is destroyed or terminated by system
.
0 Comment(s)