Are the activity data provided with a time delay?

I try to write my own datafield. However, I am a bit confused about the accessable of data. I use the compute(info) function to calculate my values and write them in a custom field to the fit file with setData(data). In case I write e.g. info.elapsedDistance to the fit file, it is delayed by one time step/second. Is it somehow possible to write the data to the current time step or in my case the time step before?

  • I find that when I just display data from ActivityInfo (not even recording it to FIT), there's a delay of roughly 1 second, so I don't think there's much you can do about it.

    Is it somehow possible to write the data to the current time step or in my case the time step before?

    If you wanted to be in sync with native data, wouldn't you have to display/write data from 1 second in the *future*?

    e.g. If I get the data for 1:20 at 1:21, then it's already too late for me to write 1:20's data.

    Unless you mean that you want to delay writing of native data by one second, which isn't possible.

  • That's not so good if you have also a delay of 1 second to display something. That would mean that it is a default behavior having a delay. (I haven't checked the display delay but I think it is in the line with the compute() call in my case. At least I get simultanous outputs on simulator and System.println())

    I want to write my data in line with the native data. Following you example, I get the data for 1:20 at 1:21, so that I can only write the 1:20 data with an delay of 1 second at 1:21. Of course, I can change the fit files later on to have the data in line but I prefer to have it correct out of the device. 

  • That would mean that it is a default behavior having a delay.

    Yes, that's what I was alluding to. You can test this easily by reading ActivityInfo.timerTime, formatting it as [hh]:mm:ss, displaying it in your data field, and testing your data field alongside the native Timer field. When I've done this (as part of a more complex app), I've seen a delay of approximately 1 second. (Sometimes the delay can be longer or shorter)

    I want to write my data in line with the native data.

    Yes I understand that but it's not possible for you to write your own delayed data "in the past" so to speak.

    I think the only way to theoretically accomplish what you want would be to delay the writing of all other (native) data, which also isn't possible.

  • When you do a setData, that doesn't write to the fit.  Fit files are written at most every second, so your setData may be written a second later.

    That's just the way it works.

  • That's pity but thank you for confirming my impression and checking my code indirectly.