title: How to read Heart Rate history from Google Fit API in Android?
body: <p>I tried to read data from Fit API history like following,</p>
  
  <pre><code> private DataReadRequest queryFitnessData() {
      Calendar cal = Calendar.getInstance();
      Date now = new Date();
      cal.setTime(now);
      long endTime = cal.getTimeInMillis();
      cal.add(Calendar.DATE, -10);
      long startTime = cal.getTimeInMillis();
  
      SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
      Log.i(TAG, "Range Start: " + dateFormat.format(startTime));
      Log.i(TAG, "Range End: " + dateFormat.format(endTime));
  
      DataReadRequest readRequest = new DataReadRequest.Builder()
              .aggregate(DataType.TYPE_HEART_RATE_BPM, DataType.AGGREGATE_HEART_RATE_SUMMARY)
              .bucketByTime(1, TimeUnit.DAYS)
              .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
              .build();
  
      return readRequest;
  }
  </code></pre>
  
  <p>And I read the data like following,</p>
  
  <pre><code>DataReadRequest readRequest = queryFitnessData();
  
          // [START read_dataset]
          // Invoke the History API to fetch the data with the query and await the result of
          // the read request.
          DataReadResult dataReadResult =
                  Fitness.HistoryApi.readData(mClient, readRequest).await(1, TimeUnit.MINUTES);
  </code></pre>
  
  <p>I evaluated the output using debugger for <code>dataReadResult</code>      </p>
  
  <p><img src="https://i.stack.imgur.com/CpzVO.png" alt="enter image description here">      </p>
  
  <p>how can i fix this?</p>
  
  <p>Thanks in Advance!!</p>