Activity-Fragment
Activity Manager in Android Framework and Fragment related things.
A complete Activity and Fragment lifecycle below:
Activity:
- onCreate() is called -> saveInstanceState = null, no state for the application
- onStart() and onResume() runs when the app runs
- onPause() - onStop() - onDestroy() are called sequentially when pressing the BACK button
- onPause() - onStop() are called when pressing the HOME button
- onRestart() - onStart() - onResume() are called when return to the activity
Fragment:
- onAttache(): attach the fragment to activity
- onCreate(): create the fragment itself
- onCreateView(): create the fragment UI
- onStart()/onResume() are similar to the activity
- onPause()/onStop()/onDestoryView()/onDestroy are called before the corresponding method of Activity
- onDetach()