Android Notes

Table of Contents

  1. Activity and App destruction
  2. Activity Lifecycle

TODO:

Activity and App destruction

The system never kills an activity directly to free up memory. Instead, it kills the process in which the activity runs, destroying not only the activity but everything else running in the process, as well.

Android Docs

onDestroy is called when your Activity is finished (either through calling finish or the user hitting back) but not when the entire App is finished. Therefore onDestroy should be used for cleaning up your program state and freeing up memory - neither of which matter if the app is killed.

If a Task consists of Activities from multiple different Apps, an App who’s Activity is in the background may be killed. When the user navigates back to that Activity, the App is restarted.

Activity Lifecycle

Android Activity Lifecycle diagram

Android Docs