This seems like something that should be easy to solve but I always get a null value when trying to getValue some storage data. I want to make 2 customizable fields in the app settings. These are the properties, settings, and string.xml files, with 2 fields:
<properties> <property id="Lat_u" type="float">38.8551</property> <property id="Lon_u" type="float">-94.8001</property> </properties>
<settings> <setting propertyKey="@Properties.Lat_u" title="@Strings.Latitude"> <settingConfig type="numeric" required="true"/> </setting> <setting propertyKey="@Properties.Lon_u" title="@Strings.Longitude"> <settingConfig type="numeric" required="true"/> </setting> </settings>
<strings> <string id="AppName">Test</string> <string id="Latitude">Latitude</string> <string id="Longitude">Longitude</string> </strings>
Then I have a background event, registered in the getInitialView() of the app, that tries to load the data like so:
using Toybox.Application.Storage; ... (:background) class BgbgServiceDelegate extends Toybox.System.ServiceDelegate { var APIKEY = ... var home_lat = Storage.getValue("Lat_u"); var home_lon = Storage.getValue("Lon_u"); function onTemporalEvent() { ... Sys.println(home_lat); ... }
I use the simulator to launch a background event. Before doing so I go to the App Settings Editor in Eclipse, select my app, and send the (unchanged) settings (I don't know if that is actually necessary given that I have defined some default values). Both fields are null when I try to load/print them from the app initialize() as well. Testing for the 645M.