I have a fragment which has its own state (selected buttons, etc). That state is lost on a screen rotation.
The activity that contains the fragment has a portrait la
You can enable myFragment.setRetainInstance(true)
to retain the state, but it does this 'automatically', i.e. it retains the values assigned to your class members and does NOT use the onSaveInstanceState (and hence savedInstanceState is always null).
Make sure the FragmentActivity
that hosts this fragment does not override onSaveInstanceState
or when it does it should call super.onSaveInstanceState(Bundle)
.