I am designing an Android App.
My aim is that if the App is killed while it was in the background, and if the user starts the app again then it should have the option to resume the App.
Now, my onStart function is called in two scenarios:
- When the activity is started for the first time
- Even if the activity started after the kill.
I want to check which can determine in the onStart(), that the app started from scratch, or it is resuming from previous state?
You can use shared preferences for tasks like these.
In your onStop() function, set a flag in shared preferences like:
In your onStart(), retrieve the preference and check it like this:
for more info on shared preferences, see official docs here:
http://developer.android.com/guide/topics/data/data-storage.html#pref