Search code examples
androidandroid-activitylifecycle

Activity side-by-side lifecycle


Imagine that I have an Activity A and I'm starting a new activity B from that one.

What will be the Activities lifecycle side-by-side?

 1. A: onCreate 
 2. A: onStart 
 3. A: onResume

on A => startActivity(B)

 4. B: onCreate
 5. B: onStart

 6. A: onPause

 7. B: onResume

 8. A: onStop

Is this correct?


Solution

  • Almost correct, just a minor difference. first A.onPause() and then B.onCreate()... etc

    A: onCreate
    A: onStart
    A: onResume
    

    on A => startActivity(B)

    A: onPause
    B: onCreate
    B: onStart
    B: onResume
    A: onStop
    

    Check this link for complete details

    http://developer.android.com/guide/topics/fundamentals/activities.html#CoordinatingActivities