I'm using FragmentActivity and Fragments.
When the application starts:
FragmentActivity onCreate() <------
FragmentActivity onStart()
FragmentActivity onResume()
Fragment onAttach()
Fragment onCreate() <------
Fragment onCreateView()
Fragment onActivityCreated()
Fragment onStart()
Fragment onResume()
Everything is OK, FragmentActivity onCreate() is called before Fragment onCreate(). And when I rotate:
Fragment onPause()
FragmentActivity onPause()
Fragment onStop()
FragmentActivity onStop()
Fragment onDestroyView()
Fragment onDestroy()
Fragment onDetach()
FragmentActivity onDestroy()
---
Fragment onAttach()
Fragment onCreate() <----------
FragmentActivity onCreate() <---------
Fragment onCreateView()
Fragment onActivityCreated()
Fragment onStart()
FragmentActivity onStart()
FragmentActivity onResume()
Fragment onResume()
Fragment onCreate() is called before FragmentActivity onCreate(). Why is it inconsistent?
In FragmentActivity onCreate() I generate some data, which Fragment onCreate() gets. Because of that strange behaviour I had to move my code from Fragment onCreate() to Fragment onCreateView() to be sure that my data had been generated before.
I'm using FragmentStatePagerAdapter to hold Fragments, maybe that is the reason?