Dev.to
7/10/2026

Architecting a background-controlled sound manager that actually survives Doze mode
Short summary
The author built Muffle, an Android app that automatically manages sound profiles based on context (geofencing, time triggers). The key engineering challenge was surviving Android's aggressive Doze mode battery optimization. The solution combines a Foreground Service with AlarmManager's setExactAndAllowWhileIdle for wake-ups, uses GeofencingClient instead of LocationManager to avoid battery drain, and requires NotificationPolicyAccess permission for DND overrides. Reboot persistence also needed explicit handling.
- •Foreground Service + AlarmManager.setExactAndAllowWhileIdle ensures triggers fire even in Doze mode
- •GeofencingClient from Google Play Services avoids battery drain that causes Android to revoke background privileges
- •NotificationPolicyAccess permission is required for AudioManager changes when DND is enabled
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



