Why would my Fragment be flapping during app startup?!?
02-10 11:41:34.699: D/SessionDetailFragment(19272): onResume() 99
02-10 11:41:34.699: D/MPQAudioFragment(19272): onResume() 00
02-10 11:41:34.699: D/MPQAudioFragment(19272): onResume() 99
02-10 11:41:34.699: D/SessionDetailFragment(19272): onPause() 00
02-10 11:41:34.699: D/MPQAudioFragment(19272): onStop() 00 bound_flag: false
02-10 11:41:34.699: D/MPQAudioFragment(19272): onStop() 05 mAudioService: null
02-10 11:41:34.699: D/SessionDetailFragment(19272): onStop() 00 bound_flag: false
02-10 11:41:34.699: D/SessionDetailFragment(19272): onStop() 05 mAudioService: null
02-10 11:41:34.709: D/SessionDetailFragment(19272): onDetach() 00
02-10 11:41:34.709: D/SessionDetailFragment(19272): onAttach() 00
02-10 11:41:34.709: D/SessionDetailFragment(19272): onAttach() 10 activity:MPQMainTabActivity
Note that as soon as SessionDetailFragment
completes onResume()
(as does its sub-Fragment MPQAudioFragment
), they immediately run onPause()
?!?! Then as soon as the fragment is torn down, it again begins the onAttach()
routine?
Fortunately this flapping only seems to occur once, but it makes maintaining state a bit more challenging (and I would like to understand what is happening and why).
UPDATE:
For now, I'm working around the flapping problem by using static
member attributes for key data.
This SO post points to cases where onSaveInstanceState()
does not get called, and potential workarounds: https://stackoverflow.com/a/2909211/1742657