UsageStatsManager没有为时间间隔提供适当的数据

时间:2018-10-15 11:31:15

标签: android usagestatsmanager

我正在使用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点。怎么了?

0 个答案:

没有答案