0

I just put log tags on most activity and fragment methods and this is the result:

06-19 16:33:11.934: I/Fragment Activity:MainMenuPager(15820): onCreate - BEGIN
06-19 16:33:11.958: I/Fragment Activity:MainMenuPager(15820): onCreate - END
06-19 16:33:11.958: I/Fragment Activity:MainMenuPager(15820): onStart - BEGIN
06-19 16:33:11.958: I/Fragment Activity:MainMenuPager(15820): onStart - END
06-19 16:33:11.958: I/Fragment Activity:MainMenuPager(15820): onResume - BEGIN
06-19 16:33:11.958: I/Fragment Activity:MainMenuPager(15820): onResume - END
06-19 16:33:11.973: I/HomeFragment(15820): onAttach- BEGIN
06-19 16:33:11.973: I/HomeFragment(15820): onAttach- BEGIN
06-19 16:33:11.973: I/HomeFragment(15820): onCreate- BEGIN
06-19 16:33:11.973: I/HomeFragment(15820): onCreate- END
06-19 16:33:11.973: I/HomeFragment(15820): onCreateView- BEGIN
06-19 16:33:11.981: I/HomeFragment(15820): onCreateView- END
06-19 16:33:11.989: I/HomeFragment(15820): onActivityCreated- BEGIN
06-19 16:33:11.989: I/HomeFragment(15820): onActivityCreated- END
06-19 16:33:11.989: I/HomeFragment(15820): onStart- BEGIN
06-19 16:33:11.989: I/HomeFragment(15820): onStart- END
06-19 16:33:11.989: I/MyProcessListFragment(15820): onAttach- BEGIN
06-19 16:33:11.989: I/MyProcessListFragment(15820): onAttach- BEGIN
06-19 16:33:11.989: I/MyProcessListFragment(15820): onCreate- BEGIN
06-19 16:33:11.989: I/MyProcessListFragment(15820): onCreate- END
06-19 16:33:11.989: I/MyProcessListFragment(15820): onCreateView- BEGIN
06-19 16:33:12.012: I/MyProcessListFragment(15820): onCreateView- END
06-19 16:33:12.012: I/MyProcessListFragment(15820): onActivityCreated- BEGIN
06-19 16:33:12.012: I/MyProcessListFragment(15820): onActivityCreated- END
06-19 16:33:12.012: I/MyProcessListFragment(15820): onStart- BEGIN
06-19 16:33:12.012: I/MyProcessListFragment(15820): onStart- END

So why all the logged activity methods run all first and then all Fragment ones???should the fragment one's run between the various activity states???

Maxrunner
  • 1,955
  • 4
  • 24
  • 41
  • The MainPager FragmentActivity is using a view pager, is that the reason why the lifecycle might be "wrong"?? – Maxrunner Jun 19 '12 at 16:15
  • What do you mean by "all activity methods"? You didn't put log statements in onPause(), onStop() and onDestroy()? Would you expect the activity to start the fragments before it has properly started itself? – Christine Jun 19 '12 at 16:32
  • According to this http://stackoverflow.com/questions/8729290/fragment-activity-lifecycles-and-orientation-change, onAttach from fragment runs before onStart from Activity... – Maxrunner Jun 19 '12 at 17:23

1 Answers1

1

Sorry I dont see an issue here. First, you have a pager, and we don't know at one point you set the adapter. Are you setting it in onResume? B/c I'm guessing that would match up with your output.

What kind of output do you see if you embed a <fragment /> in the layout? What kind of output would you see if you add a fragment via FragmentTransaction with-in an onClick listener? These would all have different logging outcomes so the question here is more of a game of "guess how I wrote my code".

dskinner
  • 10,527
  • 3
  • 34
  • 43