Reputation: 2684
UsageStatsManager manager = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE);
UsageEvents events = manager.queryEvents(range[0], range[1]);
//range[0] is 25th April,2018 converted in long, and range[1] is May 25,2018 in long
The query returns event starting from May 18,2018, but I clearly added April 25th as the date. Is there any other way to retrieve the whole month usage stats?
Upvotes: 0
Views: 765
Reputation: 42417
This is by design. The docs for UsageStatsManager.queryEvents() say the following (emphasis mine):
Query for events in the given time range. Events are only kept by the system for a few days.
To look back further in time, try UsageStatsManager.queryUsageStats().
Upvotes: 2