10
votes

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?

2
Testing this with Log.d() and logcat will take less time than waiting for an answer to this question...Turbo J
I was looking for a Android Developer site reference to confirm it, as the answer provided. My bad for not saying so...neteinstein

2 Answers

15
votes

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

4
votes

There is a beautiful app in the developer's site which shows the activity lifecycle, pls have a look at it.You can download the app's source code here. Thought it might help someone :).