Skip to content

Latest commit

 

History

History
77 lines (67 loc) · 2.6 KB

activity.md

File metadata and controls

77 lines (67 loc) · 2.6 KB

Meanings of onStart and onResume

  • onStart ... Activity is visible.
  • onResume ... Activity has focus.

Activity lifecycle

  • onCreate()
  • onStart()
  • onRestoreInstanceState() (API 21+)
  • onNewIntent()
  • onResume()
  • onPause()
  • onStop()
  • onSaveInstanceState()
  • onDestroy()

Activity.finish()

  • calls these in order: onPause > onStop > onDestroy

Activity.isFinishing()

  • is false if the system is temporarily destroying the activity to save space.

FragmentActivity

is an Activity that can get FragmentManager.

android:configChanges

  1. Open https://developer.android.com/guide/topics/manifest/activity-element
  2. Search for Normal launches for most activities, and you will find the great table of the list of configuration changes.

android:launchMode

Examples

Each of A, B, C, and D below represents an instance of an Activity.

Example of android:launchMode="standard" (default)

Suppose that B is android:launchMode="standard".

  1. Stack
    • B
    • A
  2. Start B
  3. Stack
    • B (new)
    • B
    • A
  4. Start A
  5. Stack
    • A (new)
    • B
    • B
    • A

Example of android:launchMode="singleTop"

Suppose that B is android:launchMode="singleTop".

  1. Stack
    • B
    • A
  2. Start B
  3. Stack
    • B (reused with the new intent)
    • A
  4. Start A
  5. Stack
    • A (new)
    • B
    • A

When you repeat searching, singleTop prevents recreating SearchActivity and SearchResultActivity.