1
votes

I want to add historic training data consisting of training type / device, start / end time, power, puls, cycles per min, kilo calories. But all true the google fit history API uses data sets it seems that you can only add one datapoint at a time using com.google.android.gms.fitness.Fitness.HistoryApi.insertData. But that would not add up to a training session.

Is that true or did I misunderstand / overlooked something in the API.

PS: since there is always someone asking for code (even on a theoretical question like this) I committed a snapshot to github. The most interesting file would be GoogleFIT.kt. Of course the source is pretty much work in progress and not written ind Java but Kotlin.

1

1 Answers

2
votes

Answering my own questing again: You need to use a com.google.android.gms.fitness.data.Session and com.google.android.gms.fitness.request.SessionInsertRequest to combine the data and then add them with com.google.android.gms.fitness.Fitness.SessionsApi.insertSession.

A rather complex work but you can find a working version in GoogleFIT.kt. Look for the insertTraining method.