Activity life
Activity Life Activity life is a sequence of events that occur when an application is running. These events are triggered by the system and the application i...
Activity Life Activity life is a sequence of events that occur when an application is running. These events are triggered by the system and the application i...
Activity life is a sequence of events that occur when an application is running. These events are triggered by the system and the application itself, and they allow the application to respond to changes in the environment.
Key moments in the activity life cycle:
onCreate(): This method is called when the activity is created and the system creates the corresponding object. For example, when you create a new activity using startActivity() method, the onCreate() method of that new activity is called.
onStart(): This method is called when the activity is started and becomes visible to the user. For example, when you start an activity using startActivity() method, the onStart() method of that new activity is called.
onDraw(): This method is called whenever the UI needs to be drawn. For example, when you draw a view in your activity using invalidate(), the onDraw() method will be called.
onTouch(): This method is called whenever the user touches the screen. For example, when the user touches a button in your activity using findViewById, the onTouch() method will be called.
onPause(): This method is called when the activity is paused by the user or the system. For example, when you pause an activity using onPause() method, the onPause() method of that activity will be called.
onStop(): This method is called when the activity is stopped completely. For example, when you stop an activity using finish() method, the onStop() method of that activity will be called.
These are just some of the key moments in the activity life cycle. By understanding these events, you can control the lifecycle of your activity and respond to changes in the environment accordingly