Hello, I'm using the newly introduced UsageStatsManager (Android L) to get usage statistics for all applications for a certain time period. All works well if a predefined interval is selected, but I'm not able to get usage statistics for a few hours (e.g statistics for last 2 hours). I've tried using Calendars while passing start and end duration, and also tried my luck with System.currentTimeMillis() but I always get today's data in return (i.e the whole day).
This is how I used calendars: Calendar startCalendar = Calendar.getInstance(); startCalendar.add(Calendar.HOUR_OF_DAY, -2); Calendar endCalendar = Calendar.getInstance(); usageList = usm.queryUsageStats(interval, startCalendar.getTimeInMillis(), endCalendar.getTimeInMillis()); And for System.currentTimeMillis() : long startTime = System.currentTimeMillis() - 7200*1000 // 7200 seconds i.e. 2 hrs long endTime = System.currentTimeMillis(); usageList = usm.queryUsageStats(interval, startTime, endTime); Any help regarding this? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

