I have read different post where it is mentioned that onCleared()
of ViewModel
is called in between onDestroyView
and onDetach
. So when I leave Fragment and navigate to another Fragment
onDestroyView
is called ,then onCleared()
followed by onDestroy()
.
when I do screen rotation onDestroyView
is called and then onDestroy()
.
During rotation onCleared()
isn't called. Wondering how it understands when onCleared() method should be called.
I was expecting after I leave fragment and return to Fragment the viewModel still should be alive.
Asked
Active
Viewed 155 times
0

I.S
- 1,904
- 2
- 25
- 48
-
Seems like a duplicate of this: https://stackoverflow.com/questions/50983738/when-is-the-viewmodel-oncleared-called – Sharp Oct 12 '20 at 08:15
-
Does this answer your question? [When is the viewmodel onCleared called](https://stackoverflow.com/questions/50983738/when-is-the-viewmodel-oncleared-called) – Sammy T Oct 12 '20 at 08:26