0
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?

Md. Sabbir Ahmed
  • 850
  • 8
  • 22
MrRobot9
  • 2,402
  • 4
  • 31
  • 68

1 Answers1

2

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().

Sam
  • 40,644
  • 36
  • 176
  • 219