Application Components Flashcards
Define what an Activity is…
A UI window within the application that users can interact with. Each activity is a subclass of the Activity class ( AppCompatActivity )
Define what a Task is…
A Task is a set of related Activities that can span across a single of multiple applications.
What is the Task Back Stack?
The mechanism within a Task that manages the Activities within the Task.
What in the Stack will the resumed activity be?
At the top of the stack.
For activities that aren’t at the top of the stack, what state are they in?
A suspended state such as paused or stopped.
When are activities removed from the stack?
When they’re destroyed.
Give a real example of the back stack in usage…
If a user is in an email app viewing their listed emails page (Activity A), and they open an email (Activity B), then Activity B will be added to the top of the back stack, on top of Activity A. Then when the email is closed, Activity B will be removed from the back stack, and Activity A will be top of the stack again.
What are the 3 Activity Lifecycle states? (4th if by the book)
(Non-existant)
Stopped
Paused
Resumed
Define each of the Activity Lifecycle states…
Non-existant -> Activity is not instantiated and is not allocated memory.
Stopped -> Instantiated and allocated memory, but not visible.
Paused -> Activity is allocated memory, and is partly visible.
Resumed -> Activity is visible and can be interacted with. Only one activity can be in this state at any given time.
What are the 7 lifecycle callback methods?
onCreate() -> Brings activity into memory.
onStart() -> Becomes visible and persistent data is loaded.
onResume() -> Activity moves foreground to be interacted with.
onPause() -> Moves out of foreground.
onStop() -> Caches current state, still allocated space but not visible or interacted with.
onDestroy() -> Removed from memory.
onRestart() -> Called when stopped and about to restart.
What is a lifecycle callback? What is their purpose?
A method that the OS calls at certain stages throughout the Activity or Fragments lifecycle.
They enable management and manipulation of the application as it activities transition through different stages.
What is meant by context in Android development?
Context can be considered as an interface to the global information about the application. It acts as a handle to the environment that your application is currently running in, enabling access to system services, preferences, databases etc.
Explain the process that happens when an explicit intent is used?
The intent is sent to the Activity Manager in the Android OS. The AM then instantiates the destination activity, and sends the intent to this activity along with the associated data.
In what 2 formats can putExtra() store data associated to an intent?
- Key-Value records where the receiving intent can use the Key to extract the associated value.
- Bundle object, the associated data can be stored in a Bundle object which is added to the intent. The receiving activity can extract the data from the bundle.
When a user clicks on the application in the launcher, what is actually opening?
The launcher activity for that application is opening. This is defined using an intent filter in the applications manifest.