Android: how to determine cold start

Jason Yu picture Jason Yu · Aug 22, 2013 · Viewed 10.6k times · Source

When app being launched, how to determine it is cold start or not? By cold start, I mean the app launched from the very beginning, instead of just resumed from a previous state.

:Edit: elaborate my question: I'm trying to find the app's launch mode: cold start or warm start. Cold start means the app is never launched before or not in background, so it needs a complete launch. Warm start means it is still in background, so it can resume and start faster. How to distinguish these two start modes programmatically?

Answer

DisibioAaron picture DisibioAaron · Sep 3, 2013

If the app is still running in the background it will call onResume first and not onCreate at all.

If you mean the first time it was ever launched on a device then use sqlite or shared preferences to store data and at the beginning check to see if its there.