title: Getting wrong data from stats usage Android
body: <p>i am tying to retrieve User usage data using the Usagestats ...but i'm getting wrong data...i want to get daily usage "From 00:00:00  to 23:59:59 "</p>
  
  <pre><code>    Calendar cal = Calendar.getInstance();
  
        cal.add(Calendar.DAY_OF_WEEK, -1); \\ the missing line
  
  
      UsageStatsManager uStateManager = (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE);
     List&lt;UsageStats&gt; usageList = uStateManager.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, cal.getTimeInMillis(), System.currentTimeMillis());
  </code></pre>
  
  <p>when  i use .getTotalTimeInForeground() i get a different result than expected ? Can you help me in setting the right way cause i tried alot and different ways without getting the expected result?
  Thanks</p>