title: heart rate query returns empty set
body: <p>Trying to access my heartRate data from google fit using the History api.<br/>
  The sign in and permissions are executed correctly.<br/>
  But the query is the real issue here.
  The Data point values always seem to return empty.</p>
  <pre><code>public void setFitnessOption() {
                  fitnessOptions =
                          FitnessOptions.builder()
                                  .addDataType(DataType.TYPE_HEART_RATE_BPM, FitnessOptions.ACCESS_READ)
                                  .addDataType(DataType.AGGREGATE_HEART_RATE_SUMMARY, FitnessOptions.ACCESS_READ)
                                  .build();
                }
  
  
  
  public void requestGoogleFitPermission() {
                  ActivityCompat.requestPermissions(this,
                          new String[]{Manifest.permission.BODY_SENSORS },
                          GOOGLE_FIT_PERMISSIONS_REQUEST_CODE);
  
                  GoogleSignInAccount account = GoogleSignIn.getAccountForExtension(this, fitnessOptions);
                  GoogleSignIn.requestPermissions(
                          this,
                          GOOGLE_FIT_PERMISSIONS_REQUEST_CODE,
                          account,
                          fitnessOptions);
                }
  
  private Task&lt;DataReadResponse&gt; readHRHistoryData() {
  
                  DataReadRequest readRequest = queryHRFitnessData();
                  return Fitness.getHistoryClient(this, GoogleSignIn.getLastSignedInAccount(this))
                          .readData(readRequest)
                          .addOnSuccessListener(
                                  new OnSuccessListener&lt;DataReadResponse&gt;() {
                                      @Override
                                      public void onSuccess(DataReadResponse dataReadResponse) {
                                          Log.v(TAG, &quot;Success&quot; + dataReadResponse);
                                          printData(dataReadResponse);
                                      }
                                  })
                          .addOnFailureListener(
                                  new OnFailureListener() {
                                      @Override
                                      public void onFailure(@NonNull Exception e) {
                                          Log.v(TAG, &quot;Failture&quot;);
                                      }
                                  });
              }
  
  
  public static DataReadRequest queryHRFitnessData() {
                  Calendar cal = Calendar.getInstance();
                  Calendar cal1 = Calendar.getInstance();
                  Date now = new Date();
                  cal1.setTime(now);
                  long endTime = cal1.getTimeInMillis();
  
                  cal.add(Calendar.DATE, -1);
                  long startTime = cal.getTimeInMillis();
                  java.text.DateFormat dateFormat = DateFormat.getDateInstance();
  
                  DataReadRequest readRequest =
                          new DataReadRequest.Builder()
                                  .aggregate(DataType.TYPE_HEART_RATE_BPM, DataType.AGGREGATE_HEART_RATE_SUMMARY)
                                  .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
                                  .bucketByTime(1, TimeUnit.DAYS)
                                  .build();
  
                  return readRequest;
              }
  
  
  public static void printData(DataReadResponse dataReadResult) {
                          Log.v(TAG, &quot;Number of returned buckets of DataSets is: &quot; + dataReadResult.getBuckets().size());
                          if (dataReadResult.getBuckets().size() &gt; 0) {
                              for (Bucket bucket : dataReadResult.getBuckets()) {
                                  List&lt;DataSet&gt; dataSets = bucket.getDataSets();
                                  Log.v(TAG, &quot;Datasets: &quot; + dataSets);
                                  for (DataSet dataSet : dataSets) {
                                      dumpDataSet(dataSet);
                                  }
                              }
                          } else if (dataReadResult.getDataSets().size() &gt; 0) {
                              System.out.print(&quot;Number of returned DataSets is: &quot; + dataReadResult.getDataSets().size());
                              for (DataSet dataSet : dataReadResult.getDataSets()) {
                                  dumpDataSet(dataSet);
                              }
                          }
                      }
  
  
  private static void dumpDataSet(DataSet dataSet) {
                  Log.v(TAG, &quot;Name: &quot; + dataSet.getDataType().getName());
                  DateFormat dateFormat = DateFormat.getTimeInstance();
                  Log.v(TAG, &quot;Fields: &quot; + dataSet.getDataSource().getDataType().getFields());
  
                  Log.v(TAG, &quot;Data Point Values :&quot; + dataSet.getDataPoints());
                  for (DataPoint dp : dataSet.getDataPoints()) {
                      Log.v(TAG, &quot;Data Point:&quot;);
                      Log.v(TAG, &quot;Type: &quot; + dataSet.getDataType().getName());
                      Log.v(TAG, &quot;Start: &quot; + dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
                      Log.v(TAG, &quot;End: &quot; + dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));
                      for (Field field : dp.getDataType().getFields()) {
                          Log.v(TAG, &quot;Field: &quot; + field.getName() + &quot;, Value : &quot; + dp.getValue(field).asFloat());
                      }
                  }
              }
  
  
  
  </code></pre>
  <p>Log:</p>
  <pre><code>V/nativehealth: Successcom.google.android.gms.fitness.result.DataReadResponse@61ae9a7
      Number of returned buckets of DataSets is: 1
      Datasets: [DataSet{d:heart_rate.summary:gms:aggregated []}]
      Name: com.google.heart_rate.summary
  V/nativehealth: Fields: [average(f), max(f), min(f)]
      Data Point Values :[]
  
  
  </code></pre>
  <p>I have maintained heart rate data on my google fit app. Yet my code returns empty set.
  What am I missing out here??</p>
  <p><strong>Update:</strong><br/>
  I tried to insert data (HeartRate = 81) using HistoryClient and then I tried to read this data. It worked perfectly fine. <br/></p>
  <p>Log:</p>
  <pre><code>Datasets: [DataSet{d:heart_rate.summary:gms:aggregated [RawDataPoint{[81.0, 81.0, 81.0]@[1612494973714000000, 1612494973714000000](0,1)}]}]
      Name: com.google.heart_rate.summary
  V/nativehealth: Fields: [average(f), max(f), min(f)]
      Data Point Values :[DataPoint{[81.0, 81.0, 81.0]@[1612494973714000000, 1612494973714000000,raw=0](d:heart_rate.summary:gms:aggregated r:heart_rate.bpm:com.nativehealth:)}]
      Data Point:
      Type: com.google.heart_rate.summary
  V/nativehealth: Start: 11:16:13 AM
  V/nativehealth: End: 11:16:13 AM
      Field: average, Value : 81.0
      Field: max, Value : 81.0
      Field: min, Value : 81.0
  </code></pre>
  <p>But I couldn't see this data in my google fit app!!! This entire process is so confusing. Anyone PLEASE HELP!</p>