“Intent is a messaging object you can use to request an action from another app component. Although intents facilitate communication between components in several ways, there are three fundamental use cases: Starting an activity, Starting a service, Delivering a broadcast.”
Photo credit: @vogella
# Start the activity connect to the
# specified class
Intent i = new Intent(this, ActivityTwo.class);
startActivity(i);
“To manage limited system resources the Android system can terminate running applications. Each application is started in a new process with a unique ID under a unique user. If the Android system needs to free up resources it follows a simple set of rules.”
An application in which the user is interacting with an activity, or which has an service which is bound to such an activity. Also if a service is executing one of its lifecycle methods or a broadcast receiver which runs its onReceive() method.
User is not interacting with the activity, but the activity is still (partially) visible or the application has a service which is used by a inactive but visible activity.
Application with a running service which does not qualify for 1 or 2.
Application with only stopped activities and without a service or executing receiver. Android keeps them in a least recent used (LRU) list and if requires terminates the one which was least used.
Application without any active components.
Activity is visible and interacts with the user.
Activity is still visible but partially obscured, instance is running but might be killed by the system.
Activity is not visible, instance is running but might be killed by the system.
Activity has been terminated by the system of by a call to its finish() method.
Called then the activity is created. Used to initialize the activity, for example create the user interface.
Called if the activity get visible again and the user starts interacting with the activity again. Used to initialize fields, register listeners, bind to services, etc.
Called once another activity gets into the foreground. Always called before the activity is not visible anymore. Used to release resources or save application data. For example you unregister listeners, intent receivers, unbind from services or remove system service listeners.
Called once the activity is no longer visible. Time or CPU intensive shut-down operations, such as writing information to a database should be down in the onStop() method. This method is guaranteed to be called as of API 11.
Photo credit: The Activity Lifecycle