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 .

  • and did you try to change it?

    Or you just set it?

    Could my problem be caused by lack of memory?

  • What watch are you testing with in the sim? Is your app close to the memory limit? Is it a datafield app?

    It's a well-known issue that pushing settings to an app causes a memory spike. If the memory spike causes a data field (for example) run out of memory, then the settings changes are ignored.

    In this case, it's the opposite (your app is the one making the change). But it might still be worth trying this:

    - Start app (so that simulator starts)

    - Close app (leave simulator open -- use File > Kill App)

    - Make changes in app settings editor (to override any programmatic settings)

    - Close app settings editor and reopen app settings editor to make sure changes were applied

    - Close app settings editor

    - Start app

    - Close app again

    - Open app settings editor and check to see if programmatic changes were applied

    I know it's a pain, but this is pretty close to the workflow that I have to use when I test settings changes for data fields which are close to the memory limit (although it is the opposite of your scenario)

  • Well, my "vm" property was previously true and it changed to false (in the sim's app settings editor.)

    My "c" property (a list of colors where the key is the color name and the value is the CSS code) was previously "Light Grey" and it changed to "Green". (So programmatically changing a numerical property tied to a list setting works for me, at least in the sim's app settings editor. I don't if it will work with the real Garmin Connect app.)

    I'm not sure what's causing your problem tbh. I only know that when you do the opposite (push settings from the app settings editor or in from the phone IRL), it can cause a problem if the app is currently running. So my suggestion above probably won't help, but it would eliminate the slight possibility that there's something related.

    If you look at the sim's memory viewer, it should be obvious if you're close to the memory limit or not.

  • Thank you, I will try it.

    But what is confusing, that one part of the settings updates and the other doesn't. It is awkward behaviour, in case of some memory issue, I would expect that none would change...

  • Yeah, it's probably not it. What you said about list settings not working is much more likely, except it works for me (in the sim).

  • This is how my "c" setting is defined.

    <properties>
    	<property id="c" type="number">0xaa0000</property>
    </properties>
    
    <settings>
    	<setting propertyKey="@Properties.c"
    		title="@Strings.themeColourTitle">
    		<settingConfig type="list">
    			<listEntry value="0xaa0000">@Strings.dark_red</listEntry>
    			<listEntry value="0xFF0000">@Strings.red</listEntry>
    			<listEntry value="0xaaaaaa">@Strings.light_gray</listEntry>
    			<listEntry value="0x555555">@Strings.dark_gray</listEntry>
    			<listEntry value="0x00aaff">@Strings.blue</listEntry>
    			<listEntry value="0x0000ff">@Strings.dark_blue</listEntry>
    			<listEntry value="0xaa00ff">@Strings.purple</listEntry>
    			<listEntry value="0x00ff00">@Strings.green</listEntry>
    			<listEntry value="0x00aa00">@Strings.dark_green</listEntry>
    			<listEntry value="0xff5500">@Strings.orange</listEntry>
    			<listEntry value="0xFFAA00">@Strings.yellow</listEntry>
    			<listEntry value="0xff00ff">@Strings.pink</listEntry>
    		</settingConfig>
    	</setting>
    </settings>

  • I have a long list of settings and large custom fonts (I use filters, I tried to save every byte possible) . So the problem is probably not my code but the memory. 

    Please do you have any idea how much memory I can use? I supposed that the settings values are separate because they are physically "in the phone". Am I wrong?

  • It works for me for all of the 30 or so apps of mine that use list settings.  And I can test it in the sim without issue using eclipse.

  • Well, settings per se don't take up memory in your app, but properties do, and settings strings *might* (see below). Of course, each setting has an associated property.

    Your app receives a dictionary of property key/values which takes up memory permanently.

    That's why I my property names are so short -- each character in a property name is 1 byte of precious memory.

    And each property takes up memory.

    Furthermore, each string that you define takes up memory (if you call loadResource at least once), even if you only use the string for a setting.

    So for example, when I build the same data field app for a device with not much memory for data fields (e.g. FR235), instead of having a list of strings, I just ask the user to enter a CSS code directly. In some cases I just remove settings completely.

    But if you are coding a non-data field (widget, device app, or watchface), or your device supports music, then it's not likely that you've run out of memory (assuming you've just started building the app and haven't added a million features already.)

    You can see your current  and available memory on the status bar the bottom of the sim:

    You can also see peak memory and other stats with File > View Memory:

  • Well, any other idea? Please! I change the values onUpdate in the case onSettingChanged() was called. 

    I've been fighting it for two days...

    Could the size of my fonts influence this?