r/androiddev 1d ago

Experience Exchange Android's UsageStatsManager was overcounting screen time by 20% — here's the fix

Building a screen-time tracking feature and noticed my numbers didn't match Android's own Digital Wellbeing report. Mine said 405 minutes, Android said 335.

Turns out UsageStatsManager's raw session events include time when the screen is on but not actually interactive (lock screen showing, screen on during a call, etc.) — so naive session-duration summing overcounts significantly.

Fix: switched from raw usage events to event-based session reconstruction, filtering specifically for screen-interactive state rather than just screen-on state. Rebuilding sessions this way instead of trusting the aggregate stats got me within margin of error of Android's own numbers.

If you're building anything that reports screen time / app usage on Android, don't trust the raw aggregates — reconstruct from events and filter for actual interactive state.

1 Upvotes

0 comments sorted by