The counter that will not count
State in Compose
Repair the counter so that every click updates its label and the value survives ordinary Activity recreation on rotation.
Assume Android Compose with the Activity's standard SavedStateRegistry, a small Int value and no integer overflow. Durable storage or reopening an explicitly finished screen is outside the contract.
Check: clicks produce 0 → 1 → 2; an ordinary recomposition keeps 2; rotation restores 2; a new independent opening after finishing starts at 0. Saving UI state.
This saved draft exceeds the editor limit. Download it before resetting; the original is preserved.
An ordinary local var is not observable Compose state. MutableIntState stores an Int without ordinary JVM boxing and invalidates observing reads when its value changes; the API is available since Compose Runtime 1.5.0. mutableIntStateOf.
RememberSaveable saves a supported small value through the saved-state mechanism. This helps Activity recreation and restoration after system-initiated process death with saved state; it is not a database or a promise of restoration after finish/task removal. Save UI state. This solution was not run on Android.