- onStart ... Activity is visible.
- onResume ... Activity has focus.
- onCreate()
- onStart()
- onRestoreInstanceState() (API 21+)
- called only if savedInstanceState is not null.
-
Most of the time, you restore the activity state in onCreate(). But because onRestoreInstanceState() is called after onStart(), if you ever need to restore
- some state after onCreate() is called, you can use onRestoreInstanceState().
- onNewIntent()
- onResume()
- onPause()
- onStop()
- onSaveInstanceState()
- called after onStop() in Android P or higher.
-
If called, this method will occur after onStop for applications targeting platforms starting with android.os.Build.VERSION_CODES#P. For applications targeting earlier platform versions this method will occur before onStop and there are no guarantees about whether it will occur before or after onPause.
- onDestroy()
- calls these in order: onPause > onStop > onDestroy
- is false if the system is temporarily destroying the activity to save space.
is an Activity that can get FragmentManager.
- Open https://developer.android.com/guide/topics/manifest/activity-element
- Search for
Normal launches for most activities
, and you will find the great table of the list of configuration changes.
- https://developer.android.com/guide/components/activities/tasks-and-back-stack#ManifestForTasks
- Do the following
- Open https://developer.android.com/guide/topics/manifest/activity-element
- Search for
Normal launches for most activities
, and you will find the great table of the differences betweenstandard
,singleTop
,singleTask
, andsingleInstance
.
Each of A, B, C, and D below represents an instance of an Activity.
Suppose that B is android:launchMode="standard"
.
- Stack
- B
- A
- Start B
- Stack
- B (new)
- B
- A
- Start A
- Stack
- A (new)
- B
- B
- A
Suppose that B is android:launchMode="singleTop"
.
- Stack
- B
- A
- Start B
- Stack
- B (reused with the new intent)
- A
- Start A
- Stack
- A (new)
- B
- A
When you repeat searching, singleTop
prevents recreating SearchActivity
and SearchResultActivity
.