Search code examples
androidwear-osgoogle-fitgoogle-fit-sdk

How to calculate active time from Google Fit?


I'm developing an application to get the daily step count, calories, distance and active time from Google Fit. I calculated all of the above except for the active time. How can I do that?

I also want to know, if I got e.g. 500 steps, what the activity type is (walking/running).

Any help is appreciated


Solution

  • There's no way (afaik) to get the active time directly from the Google Fit API. You will have to get the duration of each of the recorded activities and add them together. (See sample code in this answer)

    For the second question, each recorded data point should have an activity type field. You can find a list of all of them here. Just keep in mind that you can't assume that all steps comes from the activity. Again you have to look at all the recorded activities individually.