Simulator in SDK versions > 2 : several Activity.Info members always return "null"

Since Connect IQ SDK 2.1.1, in the Simulator in "Fit data simulation mode", several Activity.Info members (but not all) always return "null".

For example, following members always return "null" :
  • Activity.Info.totalAscent
  • Activity.Info.totalDescent
  • Activity.Info.maxSpeed
  • Activity.Info.averageSpeed

Following members are OK :
  • Activity.Info.altitude
  • Activity.Info.currentSpeed

With Connect IQ SDK version 1.2.11 (and below) all these values are correctly returned. I did not test SDK 1.3 and 1.4 (no longer available on Garmin servers ?)

I have tested 3 different versions of Eclipse on a Windows 10 64 bit machine with the same behavior :
  • Eclipse Luna Service Release 2 (4.4.2)
  • Eclipse Mars.2 Release (4.5.2)
  • Eclipse Neon.2 Release (4.6.2)

Important point : on my real Epix device all these values are correctly returned => the issue appears only in the Simulator.

The best way to reproduce this issue is to create a new Simple Data Field Project, and replace "return 0;" by "return info.maxSpeed;" for example. With SDK 2.1.1 up to 2.2.4 it returns nothing, and with SDK 1.2.11 it returns a number.

using Toybox.WatchUi as Ui;

class SimpleDataFieldView extends Ui.SimpleDataField {

// Set the label of the data field here.
function initialize() {
SimpleDataField.initialize();
label = "My Label";
}

// The given info object contains all the current workout
// information. Calculate a value and return it in this method.
function compute(info) {
// See Activity.Info in the documentation for available information.
return info.maxSpeed;
}
}
  • You could see a difference based on if you use "Simulate Data" or "Playback File". Also, with 2.x.x and a DF, make sure you either click on the "start button" for the device, or use "Data Fields>Timer>Start Activity" to get things going. It's always a good practice to check everything in Activity.Info for a null as some won't have a value until recording starts (or even a bit after that).

    From the API doc for Activity.Info:
    A class containing information about the current activity. The fields in this class may return null so you should null check a value before using it.
  • ... make sure you either click on the "start button" for the device
    That's it ! I didn't catch that I had to click on the "start button" in the simulator. It was not necessary in earlier versions of the SDK.
    Thank you jim_m_58
  • Yes, that was something new in 2.x.x, and actually makes it more like actual devices work, as far as starting/pausing/saving/etc the recording.