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?
An Android activity goes through six major lifecycle stages or callbacks. These are: onCreate() , onStart() , onResume() , onPause() , onStop() , and onDestroy() .
Activity-lifecycle concepts To navigate transitions between stages of the activity lifecycle, the Activity class provides a core set of six callbacks: onCreate() , onStart() , onResume() , onPause() , onStop() , and onDestroy() . The system invokes each of these callbacks as an activity enters a new state.
If screen times out on your activity, then onPause is called. After sometime if you will not open the screen then onStop will be called.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With