> For the complete documentation index, see [llms.txt](https://notes.tejpratapsingh.com/_/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.tejpratapsingh.com/_/android-tips/lifecycle/basics/lifecycle/fragment.md).

# Fragment

Simple, without any sequence

1. `onAttach()`
2. `onCreate()`
3. `onCreateView()`
4. `onViewCreated()`
5. `onStart()`
6. `onResume()`
7. `onPause()`
   1. `onSaveInstanceState()`
8. `onStop()`
9. `onViewDestroyed()`
10. `onDestroy()`
11. `onDetach()`

{% @mermaid/diagram content="---
title: Fragment Lifecycle
-------------------------

graph TD
onAttach --> onCreate
onCreate --> onCreateView
onCreateView --> onViewCreated
onViewCreated --> onStart
onStart --> onResume
onResume --> onPause
onPause --> onSaveInstanceState
onSaveInstanceState --> onStop
onPause --> onStop
onStop --> onDestroyView
onDestroyView -- Re-Enter fragment --> onCreateView
onDestroyView --> onDestroy
onDestroy --> onDetach
" %}
