ACTIVITY LIFE CYCLE
An activity can have five states, which are :
1.Started / Running (Active)
2.Paused
3.Resumed
4.Stopped
5.Destroyed
1. Running (Active) State
When an Activity is in active state, it means it is active and running.
It is visible to the user and the user can interact with it.
Android Runtime treats the Activity in this state with the highest priority and never tries to kill it. ACTIVITYLIFE CYCLE
Check the PDF for details. https://thelyallpurtimes.com/
Stopped State
When a new Activity is started on top of
the current one or when a user hits the
Home key, the activity is brought to
Stopped state. ACTIVITYLIFE CYCLE
• The activity in this state is invisible,
• Android Runtime may kill such an
Activity in case of resource crunch.
When a user hits a Back key or
Android Runtime decides to reclaim
the memory allocated to an Activity
i.e in the paused or stopped state,
It goes into the Destroyed state.
• The Activity is out of the memory
and it is invisible to the user.
5. Destroy State ACTIVITYLIFE CYCLE
◾ Android activities go through five states during their
entire lifecycle. These activities have callback
methods() to describe each activity in each of the
four stages. These methods need to be overridden by
the implementing subclass. In Android, we have the
following 7 callback methods that activity uses to go
through the four states:
1. onCreate()
2. onStart()
3. onResume()
4. onPause()
5. onStop()
6. onRestart()
7. onDestroy()
Android Activity Methods
The Android onstart() method is invoked as soon as the activity
becomes visible to the users. This method is to start an activity. The
activity comes on the forescreen of the users when this method is
invoked.
onStart()
◾ The Android onPause() method is invoked when the activity doesn’t receive
any user input and goes on hold. In the pause state, the activity is partially
visible to the user. buttons. Once an activity is in the pause state, it can be followed by either
onResume() or onStopped() callback method.