Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 525
neteinstein Avatar asked Apr 10 '12 18:04

neteinstein


People also ask

What are the lifecycle methods of activity?

An Android activity goes through six major lifecycle stages or callbacks. These are: onCreate() , onStart() , onResume() , onPause() , onStop() , and onDestroy() .

What does activity lifecycle mean?

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.

What is the difference between onPause and onStop?

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.


1 Answers

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

like image 195
Shubhayu Avatar answered Oct 23 '22 05:10

Shubhayu