660 likes | 1.34k Views
Activity Lifecycle. Activity States . Active (running) An active activity is visible on the screen and has the focus. This is the activity the user is interacting with. P aused
E N D
Activity Lifecycle Fall 2012 CS2302: Programming Principles
Activity States • Active (running) • 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 • FirstActivity • onCreate • onStart • onResume Fall 2012 CS2302: Programming Principles
Start the second Activity from the first Activity • FirstActivity • onPause • SecondActivity • onCreate • onStart • onResume • FirstActivity • onStop Fall 2012 CS2302: Programming Principles
Come back to the first Activity • SecondActivity • onPause • FirstActivity • onRestart • onStart • onResume • SecondActivity • onStop Fall 2012 CS2302: Programming Principles
Summary Fall 2012 CS2302: Programming Principles