Again: Unexpected Type Error

Hi,

my datafield throws an unexpected type error in the CIQ_LOG.TXT file if I change too fast from the watch face to the activity screen to my data field. If I wait a second on the activity screen the data field loads quite well and there are no problems at all. Any hints what the cause is?
  • Hi,

    my datafield throws an unexpected type error in the CIQ_LOG.TXT file if I change too fast from the watch face to the activity screen to my data field. If I wait a second on the activity screen the data field loads quite well and there are no problems at all. Any hints what the cause is?


    Make sure you are not accessing something from the activity info before it is set. These fire off every 1 second.
  • Okay, thanks for that information. Nevertheless, I thought, that the constructor is called first before compute(info) is called. I am confused now.
  • There are times when the info object or its members of the object are NULL, so best to check. I do something like this:

    function compute(info)
    {
    if( info != null && info.calories != null )
    {
    ....
    }
    else
    {
    return 0.0;
    }
    }
  • Okay, did I get it right that, if one does _not_ do this:

    function compute(info) {
    if (info) {
    // do something with info
    }
    }


    he get's into the same trouble as me, i. e. the datafield may crash if a user starts the datafield to fast (from the watchface to the activity screen into the activity)?
  • The reason I started checking info was there were times when an activity was just started that info would not be initialized yet. If you search the forums, you'll see others have run into this problem as well as the info object not having every data field on every device. For example: https://forums.garmin.com/showthread.php?359697-Activity-Info-fields-not-working

    So I can't say that this is for sure what is causing your problem, but I can say that from my experience with this SDK, you need to validate and check all data before using it (properties that come back from GCM come back as strings and have to be cast to the specific data type, but come back as the correct data type from the Connect website for example).