When orientation changes, fragment viewState
restored only in onStart
.
After onAttach
, onCreateView
, onViewCreated
In Android API >= 17 (Android 4.2 Jelly Beans) there is a method:
public void onViewStateRestored (Bundle savedInstanceState)
which is called before onStart()
and after onActivityCreated()
as mentioned in docs.
In Android API < 17 there is no such method. But there are two solutions:
Fragment
and save all required initialization state as Fragment
state (i.e. override Fragment#onSaveInstanceState()
). Later you can restore fragment state in onCreate()
, onCreateView()
or onViewCreated()
.onStart()
as specified in question.