onSettingsChanged and null values

Former Member
Former Member
Hi,

I my wathface i have some parameters i read with getProperty. Everything works fine.. when i change from GCM the value the function onSettingsChanged in app is called but when i read again some properties i have null values.... any idea WHY?? the wathface crashes...


function onSettingsChanged() { // triggered by settings change in GCM

if(m_mainView)
{
m_mainView.handlSettingUpdate();

Ui.WatchUi.requestUpdate(); // update the view to reflect changes

}


thanks!!
  • Are they null, or not the expected type? See point 10 in the New Developer FAQ

    You might be expecting a Number, but you see it as a float, and point 10 has a wrapper for that.
  • Former Member
    Former Member
    hi jim,

    are null. The problem are not with the properties changed in settings but in the property i use as a sort of constant.
    Example:

    <property id="XVALUE" type="number">135</property>

    I use XVALUE as a constant to draw an object. when i change a color setting and i try read back the XVALUE is null and the app crashes.

    MAybe i have to use a string and convert to a number as u suggested me to have compile time constant ?


    thanks for your support


    PS
    I'm using an iphone
  • Former Member
    Former Member
    jim
    fixed using Ui.loadResource(Rez.Strings.FOO).toNumber().


    Marco
  • For me, if I have a property, I always have an associated setting for it (I only use properties for settings).

    If it's the apps's own data, I use the object store. (no property). An example here is saving off a location for sunrise/sunset, in the event I can't get a new one from Activity.Info.

    You got the compile time options with things like a device specific string (as you are) or using annotations,etc.

    There's also a run-time option based on what you need. I'll do that in onLayout(), with things like width, height, and screenShape.

    Peter De Decker did a blog post that can give you some ideas.