Skip to content
Articles
Article

Why UsageStatsManager returned no foreground app on a real Android phone

by Andrii Zhukovskyi dev.to

3 min read

In short. If UsageStatsManager.queryEvents(now - 10s, now) returns nothing on a real phone, check dumpsys usagestats for a daily bucket dated in the future. Android files new events into that bucket after the clock was once ahead, and a query that ends at now never searches it. Query a few days past now, then ignore events stamped after now. I hit this while building Focus Sprint, my focus timer …

Forum

Questions about this, or something to add?

Discuss on the forum

Report this · Wrote this? Claim it

FlutterX is supported by