We're building ReClaim , a minimalist Android launcher that's on Google Play . The newest thing we've built for its Home screen is a practice timer: you name something you want to spend time on, like reading, and tap its Home icon to start a countdown or a stopwatch. A practice can also hold a few apps until it ends, mark a habit when it's done, and turn on Do Not Disturb while it runs.
That last option is the subject of this post. Turning Do Not Disturb on is one line of code. Turning it back off correctly is the actual work, because the phone's notification mode isn't ours. It belongs to the user, and the timer is only borrowing it. This is how our code records what it borrowed, pays it back when the process dies or the coroutine doing the paying gets cancelled, keeps that state out of backups, and where Android 15 changed the rules under us.
Stack: Kotlin, Jetpack Compose, Hilt, Room, coroutines, minSdk 26 , targetSdk 36 .…