
👨💻 Activity Lifecycle
Activity.onCreate() <- Activity is created
↓
Activity.onStart() <- Preparing to become visible on screen
↓
Activity.onResume() <- Foreground state (interactive)
↓
Activity.onPause() <- Partially visible
↓
Activity.onStop() <- No longer visible
↓
Activity.onDestroy() <- Activity is destroyed
👨💻 Compose Lifecycle
[First Composition]
  - Composable is evaluated, Compose tree is built
  - LaunchedEffect -> Runs once after the commit
  - SideEffect -> Runs after every commit
  - DisposableEffect -> onDispose is called upon disposal
↓
[Recomposition]
  - UI is re-evaluated in response to state or data changes
  - Only the necessary parts are recomposed (efficient update)
  - SideEffect and DisposableEffect are also re-evaluated during recomposition
↓
[Dispose]
  - Depends on the ComposeView's disposal condition
  - DisposableEffect's onDispose is executed
  - Disposal timing is determined by the ViewCompositionStrategy
👨💻 Activity x Compose Lifecycle
Activity.onCreate() setContent { ... } <- Sets the ComposeView
↓
[First Composition]
  - Evaluates Composables and builds the UI
  - LaunchedEffect -> Runs once after commit
  - SideEffect -> Runs after each commit
  - DisposableEffect -> Defines onDispose
↓
Activity.onStart()
↓
Activity.onResume()
↓
[Recomposition]
  - Re-evaluates necessary parts in response to state changes
  - LaunchedEffect is not re-executed (only if its key changes)
  - SideEffect / DisposableEffect are re-evaluated
↓
Activity.onPause()
↓
(ComposeView is retained)
  - UI becomes partially obscured
  - State is maintained within the Composition
↓
Activity.onStop()
↓
[Preparing for Dispose (Detection)]
  - ViewCompositionStrategy monitors disposal conditions
↓
Activity.onDestroy()
↓
[Dispose]
  - ComposeView is destroyed
  - DisposableEffect.onDispose() is executed
This is the general flow.
Here are the notes for each item:
Activity.onCreate() A lifecycle method called when an Android app's Activity is created.
- 
setContent { ... }: Sets the UI using Jetpack Compose. This sets a ComposeView as the Activity's content view. The Compose lifecycle begins.
- First Composition The Composable functions set in setContent are evaluated for the first time, and the UI is built.
LaunchedEffect: An Effect used for asynchronous processing. Runs only once after the first composition.
SideEffect: Runs after every composition commit (the timing when UI changes are applied).
DisposableEffect: An Effect used for resource cleanup. The logic defined in onDispose is executed when the Composition is disposed.
Activity.onStart() A lifecycle method called just before the Activity becomes visible to the user.
Activity.onResume() The Activity moves to the foreground and becomes fully interactive with the user.
- Recomposition Only the necessary Composable functions are re-evaluated in response to changes in State.
LaunchedEffect: It is not re-executed during recomposition. However, it will be re-executed if its key changes.
SideEffect: It is re-evaluated on every recomposition.
DisposableEffect: It is re-evaluated on recomposition, and the cleanup logic (onDispose) from the old Effect is called.
Activity.onPause() The Activity enters a paused state and becomes partially obscured.
ComposeView Retention: The UI is not destroyed; it is retained. The state is also maintained within the Composition, allowing it to be reused upon re-display.
Activity.onStop() The Activity is no longer visible. A time to prepare for cleaning up state and resources.
Preparing for Dispose (Detection) ViewCompositionStrategy: A mechanism that monitors the conditions under which the ComposeView should be disposed. It triggers the Composition's disposal based on the View's lifecycle.
Activity.onDestroy() The timing when the Activity is completely destroyed.
- Dispose The ComposeView is destroyed: The UI and state are completely released.
- DisposableEffect.onDispose(): The resource cleanup logic is called.
👨💻 Summary
The Jetpack Compose and Activity lifecycles are closely linked, with specific processes occurring at each stage, from UI initialization (setContent) to disposal (Dispose).
It is especially important to understand the differences between effects like LaunchedEffect, SideEffect, and DisposableEffect, and to manage them appropriately.
Furthermore, by efficiently reusing the UI in response to Activity state changes (like onResume or onPause) and cleaning up resources as needed, you can achieve stable application behavior.
 
		 
           
          
