app-lifecycle
Installation
SKILL.md
App Lifecycle Patterns
Android
SavedStateHandle in ViewModel
SavedStateHandle survives both configuration changes and process death:
class ProductDetailViewModel(
private val savedStateHandle: SavedStateHandle,
private val productRepository: ProductRepository
) : ViewModel() {
// Survives process death
val productId: String = savedStateHandle.get<String>("productId") ?: ""