Save
Mobile app
D. Android App Activities
Save
Share
Learn
Content
Leaderboard
Learn
Created by
JA
Visit profile
Cards (16)
Activity
A component of an application that provides a single screen with a user interface
View source
Applications
Contain multiple activities
Each activity has at least one connection with the others
Activities can start other activities to perform various actions
View source
Three states of an activity
Running
/Resumed
Paused
Stopped
View source
Running/Resumed
The activity is in the foreground of the screen and has user focus
View source
Paused
Another activity is in the foreground and has focus but is still visible
View source
Stopped
The activity is in the background and is no longer available to the user
View source
Callback methods
Methods involved in the life cycle of an activity
Allow monitoring of activities throughout their life cycles
View source
Three nested loops of callback methods
Entire
lifetime
Visible
lifetime
Foreground
lifetime
View source
Entire
lifetime
Happens between the call to onCreate() and the call to onDestroy()
Setting up of "global" state such as defining layout is performed in onCreate()
All remaining resources are released in onDestroy()
View source
Visible
lifetime
Happens between the call to onStart() and the call to onStop()
The user can see and interact with the activity
View source
Foreground
lifetime
Happens between the onResume() and the call to onPause()
The activity is in front of all other activities and is in focus
View source
Fragments
Represent a portion or a behavior of a user in an activity
Considered a modular section of an activity that has its own life cycle and receives its own input events
View source
Three essential callback methods for fragments
onCreate
()
onCreateView
()
onPause
()
View source
onCreate
()
Called when creating the fragment
Essential components of the fragment that need to be retained must be initialized within the implementation
View source
onCreateView
()
Called when the fragment's interface is about to be drawn for the first time
A null value is returned if the fragment does not provide a user interface
View source
onPause
()
Called when the user is leaving the fragment
View source