1

I am trying to show in my application the steps that the user walked per day in real time but I am not able to. I tried to get the steps using TYPE_STEP_COUNT_CUMULATIVE but I am able to get all the steps from the day that user started using the application.

When I tried to use other type, for example DELTA, it's not working. Not sure if I am missing something. I am able to get the daily steps from HISTORY API but I cannot use them for real time because UI does not allow to use await().

Any suggestions?

George Kagan
  • 5,913
  • 8
  • 46
  • 50
stake
  • 21
  • 1
  • 3
  • Try posting some code showing what you have already tried – ste-fu Nov 29 '16 at 11:45
  • actually i was using this tutorial for the real time data : https://code.tutsplus.com/tutorials/google-fit-for-android-reading-sensor-data--cms-25723 – stake Nov 29 '16 at 12:52

1 Answers1

0

The com.google.step_count.cumulative data type represents step count data as a sum since the start of the count. So this is not the one that you need.

From this documentation, it is stated here that Google Fit also provides simple access to the daily total of a specified data type. Use the [HistoryApi.readDailyTotal()](https://developers.google.com/android/reference/com/google/android/gms/fitness/HistoryApi#readDailyTotal(com.google.android.gms.common.api.GoogleApiClient, com.google.android.gms.fitness.data.DataType)) method to retrieve the data type that you specify as of midnight of the current day in the device's current timezone. For example, pass in the TYPE_STEP_COUNT_DELTA data type to this method to retrieve the daily total steps. You may pass in an instantaneous data type that has an aggregate daily total.

But, if you want a real time data, you need to use the Sensors API together with the Recording API. Source: Record Fitness Data

For more information, check this related SO question:

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31