import Toybox.Graphics; import Toybox.Lang; import Toybox.WatchUi; (:glance) class WidgetGlanceView extends WatchUi.GlanceView { public function initialize() { log("g.initialize"); GlanceView.initialize(); } public function onLayout(dc as Dc) as Void { log("g.onLayout"); } public function onShow() as Void { log("g.onShow"); } public function onHide() as Void { log("g.onHide"); } public function onUpdate(dc as Dc) as Void { log("g.onUpdate"); var text = formatTimestamp(TIME_FORMAT, null); var width = dc.getWidth(); var height = dc.getHeight(); var font = Graphics.FONT_GLANCE; var justification = Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER; dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK); dc.clear(); dc.drawText(width/2, height/2, font, text, justification); } function formatTimestamp(format as String, ts as Number?) as String { var m = ts != null ? new Time.Moment(ts) : Time.now(); var t = Time.Gregorian.info(m, Time.FORMAT_SHORT); return Lang.format( format, [ (t.month as Number).format("%02d"), // depends on FORMAT_SHORT t.day, t.hour.format("%02d"), t.min.format("%02d"), t.sec.format("%02d"), ]); } }
With the above code for my glance I see the following in the log when I run it in simulator on SDK 4.1.4 (fenix6 but also others):
1657456912 g.initialize
1657456941 g.onLayout
1657456941 g.onShow
1657456941 g.onUpdate
so there's a 29 seconds lag between initialize and onLayout. This happens even though I stopped the app in the simulator, waited more than 2 minutes, and then started it again, and according to the documentation in https://developer.garmin.com/connect-iq/core-topics/glances/ This should've called onUpdate immediately on start: "Such a device could update their glance view when it becomes visible (activated) and at least 30 seconds since last update."