As far as I know, Android kills an application after sometime if the
user is not interacting with it, in order to save memory. If the user
goes back to the application, the last activity is displayed again.
What I would like to do is that when this situations occurs, I always
would like to restart from my main activity. But only if my
application was killed, not in other scenarios.
Is there any way to do that? in the manifest for example?
Thanks in advance!
You can check whether an Activity has been resumed by checking if the bundle in the
onCreatemethod is null:If it isn’t null, your activity has been resumed from being killed.
If you’re simply pausing your activity
onResume()is called overonCreate().See the documentation here for the Activity Lifecycle.
