title: How to retrieve daily running and walking steps from Google Fit API
body: <p>It is probably a newbie question but I have lost a one day to figure out w/o success.
  I'm using Google Fit API into my Android app and I need to show some of its data like running and walking daily steps. I have managed to show data but in time unit (f.e running in x min). I need to show it in steps unit.</p>
  
  <p>The snipped below code shows how I retrieved data as time unit (in milliseconds):</p>
  
  <pre><code>  DataReadRequest readRequest = new DataReadRequest.Builder()
              .aggregate(DataType.TYPE_ACTIVITY_SEGMENT, DataType.AGGREGATE_ACTIVITY_SUMMARY)
              .bucketByTime(1, TimeUnit.DAYS)
              .setTimeRange(start, end, TimeUnit.MILLISECONDS)
              .build();
  
  
    Fitness.HistoryApi.readData(client, readRequest).setResultCallback(new ResultCallback&lt;DataReadResult&gt;() {
          @Override
          public void onResult(DataReadResult dataReadResult) {
              if (dataReadResult.getBuckets().size() &gt; 0) {
                  display.show("Bucket DataSet.size(): "
                          + dataReadResult.getBuckets().size());
                 retrieveHistoryData(dataReadResult, client.getContext());
               }
          }
  
                              .....
  
     private void retrieveHistoryData(DataReadResult dataReadResult, Context context) {
  
      int walking = 0;
      int running = 0;
      int biking = 0;
  
      for (Bucket bucket : dataReadResult.getBuckets()) {
          List&lt;DataSet&gt; dataSets = bucket.getDataSets();
          for (DataSet dataSet : dataSets) {
              display.show("dataSet.dataType: " + dataSet.getDataType().getName());
              for (DataPoint dp : dataSet.getDataPoints()) {
                   walking += getBucketData(dp, FitnessActivities.WALKING);
                   running += getBucketData(dp, FitnessActivities.RUNNING);
                   biking += getBucketData(dp, FitnessActivities.BIKING);
              }
          }
      }
  
      Log.d(TAG, Constants.KEY_WALKING_STEPS + ": " + walking);
      Log.d(TAG, Constants.KEY_RUNNING_STEPS + ": " + running);
      Log.d(TAG, Constants.KEY_BIKING_STEPS + ": " + biking);
  }
  
  private int getBucketData(DataPoint dp, String activityName) {
      int count = 0;
      for (Field field : dp.getDataType().getFields()) {
          Log.d(TAG, "Field " + field.getName() +  " " + FitnessActivities.getName(dp.getValue(field).asInt()) + " = " + dp.getValue(field).asInt() + " field.describeContents()" + field.describeContents());
          if ("activity".equals(field.getName()) &amp;&amp; activityName.contentEquals(FitnessActivities.getName(dp.getValue(field).asInt()))) {
              count +=  dp.getValue(field).asInt();
  
          }
      }
      return count;
  }
  </code></pre>
  
  <p>Tnx in advance.</p>
  
  <p>Best regards</p>
  
  <p>MB</p>