Android Lifecycle: onStart () & # 8594; onStop ()?

The Android Application Fundamentals says that after calling the onStart () method of the action lifecycle, either the onResume() or onStop() callback method. In the case of a "normal" start of activity, the system calls onCreate() , onStart() , onResume() . But does anyone know an example where onStart() - onStop() are executed one after another?

+6
android
source share
3 answers
  • From your activity, start another action that is not full-screen (for example, give it android: theme = "@android: style / Theme.Dialog").

    At this point, your first action was called onPause (), but not onStop (), because it is not in front, but still visible.

  • Press the home button.

    At this point, onStop () is called for your first action.

  • Restart the application.

    At this point, onStart () is called for your first action, but not onResume (), because it still does not have full-screen activity on top of it.

  • Press the home button.

    At this point, onStop () is called in the first action without passing onResume ().

+18
source share

In accordance with the flowchart on the presented page, it is impossible for onStop() called without calling onResume() . I could think of some potential scenario in which the system closes the application in the middle of its launch, but I do not know how and how such a script will be launched, or even if it exists.

As Tseng noted, it is possible that a task will never be brought to the fore (I think a task that synchronizes the phone with the Exchange server). I assume that such a task will never have onResume() or onPause() .

0
source share

When a user leaves your activity, the system calls onStop () to stop activity
(one). If the user returns when the action is stopped, the system calls onRestart ()
(2) quickly followed by onStart ()
(3) and onResume ()
(4). Note that no matter which script stops the action, the system always calls onPause () before calling

0
source share

All Articles