1 min readJan 16, 2019
onDetach()
has a misleading name, it is not called when you detach a fragment using FragmentTransaction.detach()
, but only when the fragment is definitely removed from its containing activity as you can see in the horrific fragments lifecycle illustration.
When the fragment is detached, it goes through onDestroyView()
, when it is re-attached it goes through onCreateView()
, onViewCreated()
, onActivityCreated()
. It’s only when you remove the fragment completely that onDestroy()
is called.