问题
In Android docs, I found a specs on Activity
lifecycle and on Fragment
lifecycle individually, but never together. It does not seem obvious as I attached a debugger to FragmentActivity
which hosts my fragment, and the life cycle is more than crazy. It looks like activity finishes first and then fragments starts, which is impossible.
Fragment's lifecycle
Activity's lifecycle
Logically, fragment should "jump into" activity's lifecycle after its onResume
and it would end before activity's onPause
, but it seems it is not happening.
Can someone either show me the lifecycle of the fragment in connection to its parent's activity or direct me to some good tutorial on this?
回答1:
Have you seen this? Fragment is created after Activity is created. It doesn't seem possible for "activity finishes first and then fragments starts" Can you post the code for that?
This is what I tested, 1 FragmentActivity , two Fragments :
来源:https://stackoverflow.com/questions/13941584/can-some-draw-lifecycle-of-fragment-and-its-parent-fragmentactivity