GoConqr has a new look! Let us know what you think.

Flashcards

Mobile App Development - Lecture 5 - Activity Lifecycle

M KB English 19 cards

Cards in this deck (19)

  1. 1What are the four Activity States?Active/Running
    Paused
    Stopped
    Destroyed
  2. 2Life cycle Activity methods:onCreate()
    onStart()
    onRestart()
    onResume()
    onPause()
    onStop()
    onDestroy()
  3. 3entire lifetimeThe entire lifetime of an activity happens between the first call to onCreate() through to a final call to onDestroy().
  4. 4visible lifetimeThe visible lifetime of an activity happens between a call to onStart() until a call to onStop().
  5. 5Instance statecurrent state of an activity:
    Which check boxes are checked
    Any text typed into text boxes
    Values of any private data fields
  6. 6foreground lifetimeThe foreground lifetime of an activity happens between a call to onResume() until a call to onPause().
  7. 7onCreateCalled when the activity is first created.
    Sets up the activity object and loads any static resources like images, layouts etc. After this method is called, the Activity object exists. think of this as the "constructor" of the activity.
  8. 8onStartThe onStart method is called every time the activity begins.
  9. 9onRestartCalled when the activity was stopped, but is about to be started again later
    Re-open any resources that onStop closed.
  10. 10onResumeActivity is "resumed" and goes to the foreground. Also called when activity is first created/loaded.
    Initializes resources that were released in onPause.
  11. 11onPauseActivity is still partially visible, but does not receive user input and cannot execute any code.
    Stop actions that consume CPU.
    Commit unsaved changes
    Release system resources that affect battery life.
  12. 12onStopActivity is no longer running.
    onPause is always called before onStop.
    onStop performs heavy-duty shutdown tasks like writing to a database.
  13. 13onDestroyEntire activity will be shut down and unloaded from memory.
    Perform any final cleanup before an activity is destroyed.
  14. 14Home ButtonPressing the Home button causes the activity to be paused and stopped.
    onPause → onStop
    The stopped activity will be destroyed when the system reclaims its memory.
  15. 15Back ButtonPressing the Back button will always destroy the activity.
    onPause → onStop → onDestroy
  16. 16LogCatUse the LogCat system for logging messages when your activity changes states.
  17. 17onSaveInstanceStateCalled when an activity begins to stop.
    This method should save any "non-persistent" state of the activity.
    Non-persistent state: Stays for now, but lost on shutdown/reboot.
  18. 18onRestoreInstanceStateCalled when an activity is recreated later.
    This method can restore any "non-persistent" state of the activity.
    This method is called by the system only if there is a saved state to restore
  19. 19SharedPreferencesA SharedPreferences object points to a file containing key-value pairs (similar to a Bundle).
    Pairs added to SharedPreferences persist after shutdown/reboot (unlike savedInstanceState Bundles).

Information

Description
Flashcards on Mobile App Development - Lecture 5 - Activity Lifecycle, created by M KB on 22/02/2018.
Created by
M KB
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?