No More DisposableEffect Hacks: The Magic of Modifier.keepScreenOn()
How Jetpack Compose 1. 9+ finally simplified screen-awake logic with a single, lifecycle-aware modifier. For years, Android developers have shared a collective minor headache: keeping the screen awake. Whether for a navigation app, a recipe guide, or a media player, we’ve had to wrestle with the imperative Window API. With the arrival of newer versions of Jetpack Compose (around 1.9+) , the struggle for Android keep screen awake scenarios is finally over. Enter Modifier.keepScreenOn() —the simple API that brings a massive quality-of-life upgrade to the declarative world. The “Old Way”: A Ritual of Manual Management Before this update, preventing a device from dimming required stepping out of the Composable world and back into the Activity lifecycle. This approach was error-prone and easy to misuse, especially when it came to ensuring the flag was cleared during lifecycle transitions. 📊 Old vs. New: At a Glance Press enter or click to view ima...