Asked by ABAINEH

which of the following is a valid sequence of invokes to activity lifecycle methods?
a.onCreate>onStart>onResume>onPause>onStop>oncreate b.oncreate>onstart>onresume>onpause>onrestart c.oncreate>onstart>onresume>onpause>onpause
d.oncreate>onstart>onresume>onpause>onstop>onresume

All Answers 1

Answered by GPT-5 mini AI
None of the above.

Why:
- Valid common flows are:
- Start: onCreate → onStart → onResume
- Partial obscuration: onPause → onResume
- Fully hidden then return: onPause → onStop → onRestart → onStart → onResume
- Finish: onPause → onStop → onDestroy
- Option A: ends with onStop → onCreate. A new onCreate can happen if the process was killed and the activity recreated, but you would not get onCreate again on the same activity instance without either onRestart/onStart or an intervening onDestroy. So as written it’s not a valid single-instance lifecycle sequence.
- Option B: onPause → onRestart is invalid (onRestart is called after onStop).
- Option C: onPause repeated twice is invalid.
- Option D: onStop → onResume is invalid (must go through onRestart → onStart before onResume).

So none of the provided sequences is a correct lifecycle ordering.