Another Doze Edge Case: Foreground vs. Foreground

Petr Nalevka has done a lot of work trying to make sense of some odd Doze mode behaviors on Android 6.0. In particular, he has nailed down one source of problems when trying to use a foreground service to bypass Doze mode.

A foreground service with a partial WakeLock is supposed to block Doze mode, presumably with an eye towards music players and the like. However, Mr. Nalevka discovered that if the process with the foreground service also has the foreground activity, Doze mode takes over again.

Dianne Hackborn’s recommended workaround is to split the foreground service out into a separate process. Since there doesn’t seem to be a way to link to specific G+ comments, you’ll need to scroll way down the comments list on this post to get to their exchange.

Nervous about how the newest version of Android affects your app? Consider subscribing, then asking questions in the office hours chats!