2

I have an Activity A and Activity B. Activity A starts Activity B.

Is there a guarantee that A's onPause() will always be called before calling B's onResume()?

This is related to this entry

Community
  • 1
  • 1
Mark Pazon
  • 6,167
  • 2
  • 34
  • 50

3 Answers3

4

Found the answer here:

When activity B is launched in front of activity A, this callback will be invoked on A. B will not be created until A's onPause() returns, so be sure to not do anything lengthy here.

Mark Pazon
  • 6,167
  • 2
  • 34
  • 50
2

onPause ()

When activity B is launched in front of activity A, this callback will be invoked on A. B will not be created until A's onPause() returns, so be sure to not do anything lengthy here

http://developer.android.com/reference/android/app/Activity.html#onPause()

Timmetje
  • 7,641
  • 18
  • 36
  • Yes, B will not be "created" (Does this created means onCreate?), but what will happened if B is already created? for example, B is in stop status? – Hui.Li Oct 13 '15 at 05:59
0

Yes. Activity A's onPause() will be called before passing to Activity B's onResume() if the navigation is not the first time. If navigating to Activity B is for the first time, then Activity B's onCreate() will be called after Activity A's onPause(). Take a look at Activity's Lifecycle for clear understanding.

Avadhani Y
  • 7,566
  • 19
  • 63
  • 90