Search code examples
androidandroid-activityandroid-serviceandroid-lifecycle

When an app is killed does all services in it also always killed?


When an app is killed (by the system or by swiping up in the recent apps window) does all services in it also always killed? as far as I know services are killed and maybe restarted immediately after if need, but they are killed. Can someone can confirm or infirm me this behavior ?


Solution

  • In short -- yes, that's true. The Android Dev Docs on Activity state and ejection from memory say, that

    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.

    An app consists of at least one activity. Killing the app is equal to killing the last activity. I won't go into details as you didn't ask for them, but in case you're interested, the Docs' site on the activity lifecycle is a suitable starting point.