Thursday, April 7, 2011

Android Activity Life Cycle on different cases

After published a game on market place, I decided to strengthen my knowledge of Android again.

First, start from Activity Life Cycle. Though the developer site of official Android explained the life cycle of activity with a lot text, it is still a little confusing or not clear enough. Thus I test it through by set break points during the whole life cycle. This is the result.

New Start:
onCreate(),
onStart(),
onResume().

Rotate Device:
onSaveInstanceState(),
onPause(),
onStop(),
onDestroy(),
onCreate(),
onStart(),
onRestoreInstanceState(),
onResume().

Other activity overlayed(e.g.Home button pressed,Calls in or other activity opened):
onSaveInstanceState(),
onPause(),
onStop().

Back from other activity(Not destroyed yet):
onRestart(),
onStart(),
onResume().

Back button pressed/finish() called:
onPause(),
onStop(),
onDestroy().

Screen Off:
onSaveInstanceSave(),
onPause().

Screen back on:
onResume().

No comments:

Post a Comment