Fragment
The life cycle of the high version is a bit different from before. Probably SDK28 began to be revised. Here it Activity
is compared with the records as follows; the program running version SDK30
YM--Activity: onCreate-->super_before
YM--Activity: onCreate-->super_after
YM-Fragment>: onAttach()
YM-Fragment>: onCreate()
YM--Activity: onCreate-->setContentView_after
YM-Fragment>: onCreateView()
YM-Fragment>: onStart()
YM--Activity: onStart()
YM--Activity: onResume()
YM-Fragment>: onResume()
YM-Fragment>: onPause()
YM--Activity: onPause()
YM-Fragment>: onStop()
YM--Activity: onStop()
YM-Fragment>: onDestroyView()
YM-Fragment>: onDestroy()
YM-Fragment>: onDetach()
YM--Activity: onDestroy()
The following flow can be remembered here, most of which are the first executed Fragment
life cycle followed by Activity
the second executed life cycle. Except for onResume()
the function, the function is triggered first Activity
, followed by Fragment
. In fact, it is understandable, after all , it Fragment
is attached to Activity
it, so it needs Activity
to receive the focus first, and then pass it to theFragment