What I try to do is following:
- start a workout
- add custom fields to it
- stop it
But I can't get this working - at least the part with the custom fields...
I would like to add native exercises and reps but as far as I've found out no one ever achieved this and this seems to be not possible... So alternatively I want to add custom fields to my workout session. Here's what I do:
Code
// create a session session = ActivityRecording.createSession({ :sport => ActivityRecording.SPORT_TRAINING, :subSport => ActivityRecording.SUB_SPORT_STRENGTH_TRAINING, :name => "Workout" }); // create 2 custom fields fExercises = session.createField("Exercises", 1, FitContributor.DATA_TYPE_UINT32, { :mesgType => FitContributor.MESG_TYPE_RECORD, :units => "s" }); fTotalSets = session.createField("Sets", 2, FitContributor.DATA_TYPE_UINT32, { :mesgType => FitContributor.MESG_TYPE_RECORD, :units => "sets" }); // then I start the session and add exercises/sets session.start(); // ... session is running, data is saved to my data models session.stop(); // finally I save the session and copy the data from my data model fExercises.setData(workout.exercises); fTotalSets.setData(workout.sets); session.save();
XML Definition
<fitContributions> <fitField id="1" displayInChart="true" displayInActivitySummary="true" sortOrder = "0" precision="0" chartTitle="@Strings.fit_exercises" dataLabel="@Strings.fit_exercises" unitLabel="@Strings.fit_unit_s" fillColor="#FF0000" /> <fitField id="2" displayInChart="true" displayInActivitySummary="true" sortOrder = "0" precision="0" chartTitle="@Strings.fit_sets" dataLabel="@Strings.fit_sets" unitLabel="@Strings.fit_unit_sets" fillColor="#00FF00" /> </fitContributions>
Result
The session is saved successfully and heart rate and duration is fine (on my real device) but the custom data does not show up anywhere.
When trying to debug this with monkey graph, I don't see anything at all though like following:
Any ideas what I'm doing wrong here?