Android's UsageStatsManager returning data for minimum one day, but I want to get accurate data from 12 am to the current time. I tried several types but nothing works properly. The "Action Dash" and "Digital Wellbeing" is getting data accurately.
Asked
Active
Viewed 924 times
1 Answers
2
Use queryEvents method of UsageStatsManager class.
I've recently built an app for tracking daily app usage. Firstly, I tried using queryUsageStats but it didn't work properly. I thought it was supposed to return usage time from 12 am to current time when INTERVAL_DAILY is passed to it, but instead it was returning something else. Maybe there is a bug or there is something wrong on my side related to time zone or something.
Anyway, then I tried queryEvents and it worked fine.
Here's my implementation (See both the question and the accepted answer).

Rob
- 14,746
- 28
- 47
- 65

Tanjim Ahmed Khan
- 650
- 1
- 9
- 21