You are on page 1of 3

1. What is the Activity Life Cycle?

The activity lifecycle is the set of states an activity can be in during its entire lifetime,
from the time it's created to when it's destroyed and the system reclaims its resources.
As the user interacts with your app and other apps on the device, activities move into
different states.

2. What is a task backstack?

A task is a collection of activities that users interact with when performing a certain job.
The activities are arranged in a Stack called Back Stack. The Stack has LIFO structure
and stores the activities in the order of their opening. The Activities in the Stack are
never rearranged. The navigation of the back stack is done with the help of the Back
button.

3. What are the activity states as depicted in the Activity Life Cycle?

▪ Activity Launched
▪ Activity Running
▪ App Process Killed
▪ Activity Shut Down

4. What are the methods involved in the Activity Life Cycle? Explain the typical
workflow of each method.

The methods involved in the Activity Life Cycle are:

▪ onCreate(): Called when the activity is first created.


▪ onStart(): Called just after its creation or by restart method after onStop(). Here
Activity start becoming visible to user.
▪ onResume(): Called when the activity is visible to user and user can interact with
it.
▪ onPause(): Called when the activity content is not visible because user resume
previous activity.
▪ onStop(): Called when the activity is not visible to user because some other
activity takes place of it.
▪ onRestart(): Called when user comes on screen or resume the activity which was
stopped.
▪ onDestroy(): Called when the activity is not in background.

5. Provide an explanation of how the user interact with an application navigating


through the Activity Life Cycle.

When a user launches an app, let’s say YouTube to watch a video, onCreate() is called
then onStart() followed by onResume() where the user is now interacting with the
application such as watching a video, this means that the activity is running. After
watching, the user decides to go to Facebook, now the onPause() is called when the
user clicks the home button. The user looks for Facebook and selects the app then the
onStop() method is called to stop the activity of YouTube, when Facebook launches,
the onCreate(), onStart(), and onResume() methods are called.
After using Facebook the user decides to go back to YouTube by pressing the back
button, the methods onPause(), onStop(), and onDestroy() is called. When the user
navigates back to YouTube, the methods onRestart(), onStart() and onResume() is
called, the screen visible to the user is the same screen that he/she left when
navigating to Facebook.

You might also like