1

I'm working on an Android app that uses Google Fit API.

So far I've successfully fetched step deltas with

.aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA)

but at the moment I'm stuck with this one:

.aggregate(DataType.TYPE_CALORIES_EXPENDED, DataType.AGGREGATE_CALORIES_EXPENDED)

It seems like it works partially, because i get DataSets of type com.google.calories.expended, but they dont't have any DataPoints. Here is what i get:

DataSet{d:calories.expended:gms:aggregated []}

I was testing this on data from last 7 days, and it looks like that anytime. I couldn't find any informations on how calories are, or if they are measured via API, but as far as API collects steps, your weight and body height (which i filled in some time ago) then there is no reason not to measure it so it's ready for consuming.

So there are two questions: can I get AGGREGATE_CALORIES_EXPENDED not-null values, and if yes, then how?

cyborg86pl
  • 2,597
  • 2
  • 26
  • 43
  • Did you subscribed Recording API for `DataType.TYPE_CALORIES_EXPENDED` ? – Armin Jul 15 '15 at 19:15
  • I am stuck having the exact same problem... Any solutions? Also... is it possible to query for steps and calories the same time? Also the number of active minutes per bucket would be nice to know... – Georg Mar 16 '17 at 15:19
  • @Georg for the record - I checked my code now and I did NOT get this working, sadly... – cyborg86pl Mar 16 '17 at 15:34
  • It's now working for me... This is how I do it... `aggregate(DataType.TYPE_CALORIES_EXPENDED, DataType.AGGREGATE_CALORIES_EXPENDED)` just like you... and then `dp.getValue(Field.FIELD_CALORIES).asFloat();` not sure if this was your problem after all, but it's working for me that way... – Georg Mar 17 '17 at 06:58
  • Very strange... all of a sudden I have those empty-datasets as well.. I don't get it... – Georg Mar 20 '17 at 09:16

1 Answers1

0

I solved the same issue writing in the builder of the DataReadRequest only

.aggregate(DataType.TYPE_CALORIES_EXPENDED)

I asked user's activities bucked by day within the last week. In the output I obtain what I was searching for, steps, calories and other stuff day by day.

river_song
  • 11
  • 4