Cold Start and Warm Start difference in Android

1.5k Views Asked by At

As per the official Android documentation : Cold Start - "in cases such as your app’s being launched for the first time since the device booted, or since the system killed the app"

Warm Start - "The system evicts your app from memory, and then the user re-launches it.

Consider below scenario:

App A is running -> Press Home Button (App goes to background) -> Now work on other apps -> System detects memory crunch and kills app A to reclaim some memory -> Now relaunch the App A (from recent apps or launch icon)

Now is this Warm Start or Cold start ? As per the documentation of cold start - It looks cold start as the app is launched for the first time after being killed by system (in the background).

As per the documentation of Warm start - It looks the case of warm start because it is re-launched after being evicted from the memory.

Which one is actually true here ? What is it that is being missed here ?

1

There are 1 best solutions below

1
On

An example of a cold start is when you launch your app for the first time after booting your device. This can also happen when you clear the recent applications menu. Everything will be loaded from scratch and the Bundle object returned from onCreate method in your Launch Activity will be null.

The system killing your app to reclaim memory is also referred to as process death. Before this occur onSaveInstanceState is called where the system provides a bundle where the user can persist state restoration data. This bundle becomes available in onCreate when the app is started again. The app will still be on the recent applications menu and if the state is persisted and restored properly, the user should have the illusion of a warm start when they relaunch the app again.