Hello, I'm a bit new to connect iq, but manage without difficulties to produce some datafields.
Now I'm trying to test background service, as it seems to be the only way to access temperature in datafield. Is it right? If yes temperature in datafield can't get refresh more than 1 time every 5 min?
But I've got a problem :
when I manually trigger the temporal event in te simulator onTemporalEvent is not called on my service (which is well instanciated by getServiceDelegate).
Am I missing something?
Problem fixed : getServiceDelegate must return an array of service not one instance.
ps:
simulated device is ege 530 with last SDK installed and 3.2 as min version. Using visual studio code monkey C extension.
code :
import Toybox.Application; import Toybox.Lang; import Toybox.WatchUi; import Toybox.System; import Toybox.Time; import Toybox.Background; (:background) var globalMember; (:background) class TDFTemperatureApp extends Application.AppBase { function initialize() { AppBase.initialize(); $.globalMember = 0.0; //if(Background.getTemporalEventRegisteredTime() != null) { //Background.registerForTemporalEvent(Time.now()/*new Time.Duration(5 * 60)*/); //} } // onStart() is called on application start up function onStart(state as Dictionary?) as Void { } // onStop() is called when your application is exiting function onStop(state as Dictionary?) as Void { } //! Return the initial view of your application here function getInitialView() as Array<Views or InputDelegates>? { return [ new TDFTemperatureView() ] as Array<Views or InputDelegates>; } function getServiceDelegate() as ServiceDelegate{ return new MyServiceDelegate(); } function onBackgroundData(data as Application.PersistableType) as Void { System.println("App.onBackgroundData"); $.globalMember = data; } } function getApp() as TDFTemperatureApp { return Application.getApp() as TDFTemperatureApp; } (:background) class MyServiceDelegate extends System.ServiceDelegate { function initialize() { System.ServiceDelegate.initialize(); System.println("MyServiceDelegate.initialize"); } function onTemporalEvent() { System.println("MyServiceDelegate.onTemporalEvent"); $.globalMember = 1.0; Background.exit(2.0); } }