Is Activity.onStop() guaranteed to be called (API 11 +)

前端 未结 2 1129
南方客
南方客 2020-12-03 03:44

It is unclear (to me, at least) from the documentation whether Activity.onStop is guaranteed to be called. There are two places with seemingly contradictory information.

相关标签:
2条回答
  • 2020-12-03 03:55

    Is Activity.onStop() guaranteed to be called (API 11 +)

    Yes, it is guaranteed to be called on post-Honeycomb devices (API 11 +)

    Source 1: Video tutorial on Activity life cycle - taught by Google developer advocate

    Source 2: https://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

    Source 3: AndroidLifeCycle article on www.vogella.com

    0 讨论(0)
  • 2020-12-03 04:09

    If you look further down in the ActivityLifeCycle reference, it says:

    For those methods that are not marked as being killable, the activity's process will not be killed by the system starting from the time the method is called and continuing after it returns. Thus an activity is in the killable state, for example, between after onPause() to the start of onResume().

    Since this appears to re-inforce point #1, I would err on the conservative side and design and plan my code as if point #1 were true and ignore point #2.

    0 讨论(0)
提交回复
热议问题