如何获得这样的UsageStats数据,还可以这样查看?

时间:2018-05-23 08:49:51

标签: android android-layout android-studio listview usagestatsmanager

*我得到一些像这样的数据*

UsageStatsManager usageStatsManager = (UsageStatsManager) this.getSystemService("usagestats");

    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DAY_OF_MONTH, -1);
    long start = calendar.getTimeInMillis();
    long end = System.currentTimeMillis();
    List<UsageStats> stats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, start, end);
    //Map<String,UsageStats> stats =usageStatsManager.queryAndAggregateUsageStats( start,  end);



    for (int i = 0; i < stats.size() ; i++)
    {
        Log.e(TAG,"<<<<"+i+">>>>"+"--------------------------------------------------------------------------");
        Log.e(TAG,"Package Name =  "+stats.get(i).getPackageName());
        printt("First Time Stamp =  ",stats.get(i).getFirstTimeStamp());
        printt("Last Time Stamp =  ",stats.get(i).getLastTimeStamp());
        printt("Last Time Used =  ",stats.get(i).getLastTimeUsed());
        printt("Total Time Used in foreground =  ",stats.get(i).getTotalTimeInForeground());

    }

但是我如何计算和显示这样以及如何从这些可用数据中获取应用开始时间和结束时间

*show usage of app *

0 个答案:

没有答案