Activity Lifecycle Fall 2012 CS2302: Programming Principles
Activity States Active (running) Paused Stopped An active activity is visible on the screen and has the focus. This is the activity the user is interacting with. Paused A paused activity is visible on the screen but doesn’t have the focus. A paused activity can be killed when its memory is needed by the OS. Stopped A stopped activity is not visible on the screen and is likely to be killed by the system when its memory is needed. Fall 2012 CS2302: Programming Principles
Lifecycle Events onCreate() onStart() onResume() onPause() onRestart() onStop() onDestroy() Fall 2012 CS2302: Programming Principles
Start the first Activity onCreate onStart onResume Fall 2012 CS2302: Programming Principles
Start the second Activity from the first Activity onPause SecondActivity onCreate onStart onResume onStop Fall 2012 CS2302: Programming Principles
Come back to the first Activity SecondActivity onPause FirstActivity onRestart onStart onResume onStop Fall 2012 CS2302: Programming Principles
Summary Fall 2012 CS2302: Programming Principles