Hi, I have one widget where I can't get the glance view reliably visible. I haven't found the problem currently but I am not far away. One thing which could make problems is that backgrounding may interfere with glance since one function isn't annotated with glance. My hypothesis: As soon as the background is triggered once, the glance view is gone.
I have coded following:
var myTimer; (:background) class BatteryInfoApp extends App.AppBase { function initialize() { AppBase.initialize(); } (:glance) function getGlanceView() { return [ new MyGlanceView() ]; } function getInitialView() { if(Toybox.System has :ServiceDelegate) { Background.registerForTemporalEvent(new Time.Duration(300)); } initBatData(); return [ new BatteryInfoView(), new batteryInfoDelegate()]; } function onBackgroundData(data) { initBatData(); batData.checkBgData(data); } function initBatData() { if (batData == null) { batData = new batteryData(); } } function getServiceDelegate(){ return [new BgbgServiceDelegate()]; }
initBatData isn't annotated with (:glance). As soon as I do so (for trial reasons) I get an error as soon as I am within the glance view on the watch and the background process is triggered, since I haven't annotated the class batData with (:glance). I could do that but I don't want since batData needs more mem. Is there any design pattern how to handle this? I don't need batData in the glance view...
If I don't annotate the initBatData() with glance, the sim works correcly always. But on the real watch I can see the glance view for a while before it is gone forever...