Does anyone know why the `onDestory` function of a...
# android
e
Does anyone know why the
onDestory
function of a fragment wouldn’t be called when closing the app ?
s
is it called when you kill the app from the background?
e
no
s
Is on pause?
e
it is
But it’s also called when the app just goes to background. So it’s not indicative of whether the fragment was destroyed or not
e
I’m having a problem with the Fragment’s onDestroy not the Activity’s
s
As far as I know,
onDestroy()
is not guaranteed to be called unless you explicitly call
onFinish()
.
s
Also, if you use
setRetainInstance(true)
,
onDestroy
won’t be called 🙂
And fragment’s
onDestroy
is linked to its Activity’s
onDestroy
so the link from @Kris Wong is relevant:
There are situations where the system will simply kill the activity’s hosting process without calling this method (or any others) in it, so it should not be used to do things that are intended to remain around after the process goes away.
👍 1
e
Alright, thanks for the insight guys
🤖 1