title: google fit request for per minute steps
body: <p>I am trying to read the steps per minute data for the last 5 days, but it returns only 1 day's steps per minute. Below is the code I am using to get the last 5 days' steps per minute.</p>
  
  <ol>
  <li>Last 5 days' steps </li>
  <li><p>Steps per minute</p>
  
  <pre><code>private void displayMinData() {
      Calendar cal = Calendar.getInstance();
      Date now = new Date();
      cal.setTime(now);
      long endTime = cal.getTimeInMillis();
  
      int lastSyncDays=5;
      cal.add(Calendar.DAY_OF_YEAR, lastSyncDays);
      long startTime = cal.getTimeInMillis();
      try {
          String strEndTime = millisToHMS(endTime);
          String strStartTime= millisToHMS(startTime);
      }
      catch(ParseException pe)
      {
      }
      catch(Exception e)
      {
      }
  
      java.text.DateFormat dateFormat = DateFormat.getDateInstance();
      Log.e("History", "Range Start: " + dateFormat.format(startTime));
      Log.e("History", "Range End: " + dateFormat.format(endTime));
  
      //Check how many steps were walked and recorded in the last 7 days
      DataReadRequest readRequest = new DataReadRequest.Builder()
              .aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA)
              .bucketByTime(1, TimeUnit.MINUTES)
              .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
              .build();
  
      DataReadResult dataReadResult = Fitness.HistoryApi.readData(mGoogleApiClient, readRequest).await(1, TimeUnit.MINUTES);
  
      //Used for aggregated data
      if (dataReadResult.getBuckets().size() &gt; 0) {
          Log.e("History", "Number of buckets: " + dataReadResult.getBuckets().size());
          for (Bucket bucket : dataReadResult.getBuckets()) {
              List&lt;DataSet&gt; dataSets = bucket.getDataSets();
              for (DataSet dataSet : dataSets) {
                  showDataSet(dataSet);
              }
          }
      }
      //Used for non-aggregated data
      else if (dataReadResult.getDataSets().size() &gt; 0) {
          Log.e("History", "Number of returned DataSets: " + dataReadResult.getDataSets().size());
          for (DataSet dataSet : dataReadResult.getDataSets()) {
              showDataSet(dataSet);
          }
      }
  }
  </code></pre></li>
  </ol>