SetPropperty() - unable to set value defined in properties as a list

Hi, I'm not able to set propperties that are not a number, but as a list.

example:

This is how I defined the properties:

<setting propertyKey="@Properties.BackgroundColor" title="@Strings.BackgroundColorTitle">

<settingConfig type="list">
<listEntry value="0x000000">@Strings.ColorBlack</listEntry>
<listEntry value="0x555555">@Strings.ColorDarkGray</listEntry>
<listEntry value="0xAAAAAA">@Strings.ColorLightGray</listEntry>
<listEntry value="0xFFFFFF">@Strings.ColorWhite</listEntry>
<listEntry value="0xFFFFAA">@Strings.ColorSand</listEntry>

</settingConfig>
</setting>

//in my code I have something like this

var bgColor = 0x000000;

apProperties.setProperty("BackgroundColor", bgColor );

but it doesn't work.

I need to set the value in settings programmaticaly.

Have you anyone some hint? There is no info in the documentation how to manage the settings.

second question:

Why the simulator doesn't change the settings values (I tested numbers), It works in my watch, but not in the simulator .

  • How is @Properties.BackgroundColor defined? It's missing from your example.

    e.g. I'm expecting to see something like this (in a different file)

    <properties>
        <property id="BackgroundColor" type="number">0xFFFFAA</property>
    </
    properties>

    In your example it's the setting that's a list, but it seems that the underlying property is still a number (or it should be).

    (The setting is what's displayed in Garmin Connect, and the property is what the app reads/writes. Each setting maps to an underlying property but they're not the same.)

  • Things like 0x555555 are the number that's returned when that list item is selected.

    As far as testing settings in the sim, you actually do that from eclipse.

    It's under Connect IQ>App Settings editor.

  • The backgound is defined as you expeted.

        <property id="BackgroundColor" type="number">0x000000</property>

    I appologize, but I probably don't understand your answer. 

    Please can you tell me, how to change my code: apProperties.setProperty("BackgroundColor", ???????  ) ;

    I can't pass that parameter correctly so that the settings would change. 
    The other settings, that are numbers or strings work fine, but not the boolean
    values and those "lists". I don't know why.

    And I don't know why the simulator doesn't accept when the settings changed while my in watch it works.

    Please could you kick me to the right direction?

  • I was just saying that your *property* is a number, and your *setting* is a list. You said that your property was a list, which isn't quite right.

    Just wanted to make sure you understand the distinction between property and setting.

    //in my code I have something like this

    var bgColor = 0x000000;

    apProperties.setProperty("BackgroundColor", bgColor );

    but it doesn't work.

    I need to set the value in settings programmaticaly.

    What part isn't working?

    1) When you open the app settings editor in eclipse and read settings?

    2) When you call getProperty()?

    If it's 1), IIRC, app properties are not saved until you exit the app. There used to be a saveProperties() function, but it's deprecated.

    And I don't know why the simulator doesn't accept when the settings changed while my in watch it works.

    You mean that in the simulator, your programmatic properties changes aren't applied? Or changes made by the app settings editor aren't applied?

    How are you testing settings changes on the watch? Are you only referring to programmatic changes?

    If you want to test app settings with the watch and Garmin Connect, you would need to upload your app the store. (You can set it as a beta app so nobody else can see it?)

  • But I do not need to read the values, I am able to run my simulator and app setting editor, I can work with the settings.

    But what do I have to do to change the "properties " in App settings editor. 

    I need to set the property to some computed value. So that the user could see this value in his setting editor. 

    I need to transfer the value from the watch to the seetings in Phone.

    When I set a property that is "string" , it works fine , but not the colors because it is a list in the phone..

    Is there any way how to do it?

  • That's what I gathered, but I'm confused when you say it works on your watch.

    Do you mean to say you already:

    1) uploaded the app to the store

    2) tested this with the garmin connect mobile app settings

  • Sorry I was not accurate.

    1) my program changes do not appear in the setting editor in phone

    2) I tested it as a beta and the "strings" settings work - their values change.

    3) only the "radio button" and boolean settings do not change

    4) the simulator doesn't work - setProperties() doesn't make any changes - not visible at the App settings editor 

  • Yes. I uploaded and tested with the garmin connect mobile app setting.

  • Got it, thanks!

    I tested this in Eclipse with the app settings editor.

    - I added 2 setProperty() calls to my App.onStart() method

    - 1 property is a boolean, the other is a number with list setting

    - Both property changes were picked up by the app settings editor (without even restarting the app)

    - Both property changes were obviously picked up by the app (my app reads properties after App.onStart())

        function onStart(state) {
        	AppBase.setProperty("vm", false);
        	AppBase.setProperty("c", 0x00ff00);
        }
    

  • I didn't test Garmin Connect Mobile tho.