When I start my android-activity first onCreate()
is called, then onResume()
.
When I then press the back-button to return to the home-screen and tap the app-icon again, first onCreate()
is called, then onResume()
and then onDestroy()
.
My app is still active then, but doing some action result in error since onDestroy()
sets a few members to null.
Why is that?
Update: When I wait 30 seconds after pressing back everything works fine. I'm not doing anything heavy in onDestroy except setting a few variables to null and .interrupt()
ing a background-thread.
Figured this out by myself. My understanding of what an Activity
is was flawed. Of course Android calls onDestroy() on the old Activity
instance, which can happen several seconds after the new one has been constructed.
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