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 onCreate
method is null:
if(savedInstanceState != null)
If it isn't null, your activity has been resumed from being killed.
If you're simply pausing your activity onResume()
is called over onCreate()
.
See the documentation here for the Activity Lifecycle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With