Overview › Lifecycle & State Management
Lifecycle & State Management
ViewModels + Flow widely used; SavedStateHandle adoption mixed.
70
SCORE
Summary
Lifecycle ownership is mostly correct via viewModelScope + Hilt-scoped ViewModels. Process-death survival via SavedStateHandle is uneven and worth auditing.
Findings
PASS
ProcessLifecycleOwner observer
CostcoApplication registers a LifecycleEventObserver against ProcessLifecycleOwner for app-wide lifecycle events.MEDIUM
SavedStateHandle adoption
Without
SavedStateHandle, low-memory process death loses transient state (filter selections, search drafts).Recommendation: For every ViewModel that owns user input, persist key state to
SavedStateHandle; verify with "Don't keep activities" in dev settings.MEDIUM
Configuration changes
Confirm Compose screens survive rotation and dark-mode toggle without losing scroll position.
Recommendation: Use
rememberSaveable for scroll state; cover with UI tests.LOW
Listener registration
Java code (
SwipeAndDragListView.java, etc.) is leak-prone if listeners are not removed in onDestroy.Recommendation: Add LeakCanary in debug to surface offenders.
Specific findings in this category
Costco Android · Code Review Report · Generated 2026-05-07 · 626 machine-curated findings