我正在使用UsageStatsManager
来获取从凌晨12点到一天中当前时间的数据。我编写了以下代码:
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
UsageStatsManager usageStatsManager = (UsageStatsManager) getActivity().getSystemService(Context.USAGE_STATS_SERVICE);
long endTime = System.currentTimeMillis();
long beginTime = calendar.getTimeInMillis();
UsageEvents usageEvents = usageStatsManager.queryEvents(beginTime, endTime);
但是提供的结果每4或6个小时就会重置一次;例如上午6点,12点,4点,12点。怎么了?