Introduction to App Lifecycle
The mobile app lifecycle defines the various states an app goes through during usage: launch, active, background, suspended, and terminated. Proper lifecycle management ensures correct handling of transitions between states, efficient resource usage, state preservation, and a smooth user experience.
Understanding the lifecycle is critically important for managing memory, handling background tasks, preserving state, and ensuring the app responds correctly to system events. Each platform (iOS, Android) has its own lifecycle patterns and best practices.
Mobile App Lifecycle
App States
iOS App States
States:
Not Running: The app is not running.
Inactive: A transitional state.
Active: The app is running on the foreground.
Background: The app is in the background, executing code.
Suspended: The app is in memory but not executing.
Lifecycle Methods:
application:didFinishLaunchingWithOptions:
applicationWillEnterForeground:
applicationDidBecomeActive:
applicationWillResignActive:
applicationDidEnterBackground:
applicationWillTerminate:
Android Activity Lifecycle
Lifecycle Callbacks:
onCreate() - Initial creation
onStart() - Becoming visible
onResume() - Becoming interactive
onPause() - Losing focus
onStop() - No longer visible
onDestroy() - Final cleanup
onRestart() - Restarting from stopped
Process States:
Foreground process
Visible process
Service process
Background process
Empty process
State Preservation and Restoration
iOS State Preservation
UI state encoding/decoding
Automatic state restoration
Restoration identifiers
Scene state (iOS 13+)
Android State Saving
onSaveInstanceState()
ViewModel for configuration changes
SavedStateHandle
Process death handling
Background Execution
iOS Background Modes
Background fetch
Remote notifications
Background processing
Location updates
Android Background Work
WorkManager
Foreground services
JobScheduler
Background restrictions
Try it live
Everything above runs in your browser — open Hash Function Avalanche Visualizer and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.
▶ Open Hash Function Avalanche Visualizer simulation