04 App Activities

Cards (15)

  • Activity
    A component of an application that provides a single screen with a user interface
  • Activities
    • Applications contain multiple activities, each having at least one (1) connection with the others
    • Activities can start other activities to perform various actions
  • Three (3) states of an activity
    • Running/Resumed
    • Paused
    • Stopped
  • Running/Resumed
    The activity is in the foreground of the screen and has user focus
  • Paused
    Another activity is in the foreground and has focus but is still visible
  • Stopped
    The activity is in the background and is no longer available to the user
  • Callback methods
    Methods that are involved in the life cycle of an activity
  • Entire lifetime of an activity
    1. Happens between the call to onCreate() and the call to onDestroy()
    2. Setting up of "global" state such as defining layout is performed in onCreate()
    3. All the remaining resources are released in onDestroy()
  • Visible lifetime of an activity
    1. Happens between the call to onStart() and the call to onStop()
    2. The user can see and interact with the activity
  • Foreground lifetime of an activity
    1. Happens between the onResume() and the call to onPause()
    2. During this time, the activity is in front of all other activities and is in focus
  • Fragments
    • Represents 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
  • Three (3) essential callback methods for fragments
    1. onCreate()
    2. onCreateView()
    3. onPause()
  • onCreate() is called when creating the fragment, essential components of the fragment that need to be retained must be initialized within the implementation
  • onCreateView() is 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
  • onPause() is called when the user is leaving the fragment