Can u explain with lil more detail on why the state loss happens
Ashok Koyi
1

The fragment is created then put into the back stack :

onPause() -> onStop() -> onDestroyView()

The orientation changes :

destruction of the fragment : onSaveInstanceState() (the state of the view is saved) -> onDestroy() -> onDetach()

Then

recreation of the fragment : onAttach() -> onCreate() : onCreateView() does not pass and the state is not restored

The orientation changes again :

destruction of the fragment : onSaveInstanceState() (the state has not been restored and then is not savable) -> onDestroy() -> onDetach()