Event trigger for data field on Activity Save

There are events for OnTimerStop() for a data field, but I want an event for only when the user saves the activity.  Is there any way to do this?

  • I don't think so. If you're looking to save session FIT data, you can simply save it on each occurrence of onTimerStop() -- only the last write will count.

    This is similar to how lap data actually has to be saved *before* onTimerLap(), so the usual strategy is to calculate and save it every second (only the last value saved for any given lap will be counted).

    This kind of idea can be seen in the MoxyField SDK sample (except that even session data is written every second, iirc, which is unnecessary.)

  • On a real device, in may cases when you do a save or discard of an activity. you.  are retuned to either the activity loop or the watch face.

    There might be cases when it stays in the activity, so you might try onTimerReset()

  • OK. What I am trying to do won't work using onTimerStop() or other existing events.  The processing I want to do must only happen when the user saves.  I don't want bogus intermediate values.

  • When the user does a save or discard your Data Field may stop running, so you can't do anything after that.

    You could try adding some println calls for things like elapsedTime and/or timerTime to see what they are after there was a save on a real device.  It may not work the same in the sim, so use a real device. At the same time, it may work differently on different real devices.