Widgets for Fenix 6

Thanks Garmin for the SDK update, 3.1.3 allows to get watchface and data fields easily for the new watches, but doing the same job for widgets means some work...

Recompiling an "old" (fr935/fenix5) widget for the fenix6 shows only a small icon and the name of the widget which can be scrolled up and down using the keys but that's it. Does anyone have a small example source code for the new widget type?

  • Hey ,

    There have been some device side changes on how widgets work. Your widget will still act the same once you select it from that list. We've updated the SDK with a new API and View to allow you to control what is shown in this view. Right now, you are seeing the default for widgets that do not have the new APIs implemented. I don't have a specific source example, but we do have this documented in the programmer's guide and API docs. Here is the programmer's guide doc: https://developer.garmin.com/connect-iq/programmers-guide/user-interface#glancesconnectiq3.1

  • In the Sim, if you go to simulation and turn off "glance view," your widget will run in full screen.  What you're seeing his how things work on a f6 if you don't have the glance code Coleman mentioned.

  • Coleman it may be worth while to add a second widget template option to the SDK which sets up the framework for a widget with glance view.

  • The basics are really simple.  Here's the widget template project with a glance view.  One function in the AppBase, and the new class for the view.GlanceSample.zip

  • I do little in this sample, except set colors and display a line of text,

    What you do in your widget is really based on what your widget does.  For example, I'm working on one of my weather widgets where I display a subset of what can be seen when in the full screen (such as temperature)  when a user goes to full screen, I display all all the data.

  • Thanks for posting that, Jim. With a bit of trial and error, I've got a widget working in the simulator. I'd misunderstood the documentation and thought you needed to catch the start button (or equivalent) being pushed to go from the glance to the full screen - good to see I'd worked that out correctly in the end! It uses GPS, which isn't allowed in the glance view, so took a while to get it working at all, moving code out of onStart.

    So you could adapt an existing widget by adding some simple code to provide the glance view and annotating just that with (:glance)? Then everything else would run as normal in the full view.

  • Jim, that sample is very much the level of effort I put into customizing the glance view for my radar widget when I was playing last night.  There is a lot more to play with, but I am still trying to figure out how much I really want to do.

  • So you could adapt an existing widget by adding some simple code to provide the glance view and annotating just that with (:glance)? Then everything else would run as normal in the full view.

    Basically you are correct.  The key to add this to an existing widget is the addition of the getGlanceView() function to the main AppBase class.  Then adding an entirely new view which in part extends the GlanceView. 

    I believe adding the (:glance) annotation just make is easier for the compiler to exclude those functions and classes from devices that don't support glance views.  If you leave it out, everything will still work, but the compiler will give you a warning that it supports glance view but contains no annotations.

  • I believe adding the (:glance) annotation just make is easier for the compiler to exclude those functions and classes from devices that don't support glance views.  If you leave it out, everything will still work, but the compiler will give you a warning that it supports glance view but contains no annotations.

    When running in glance mode, the app has less memory available to it. The (:glance) annotation lets you specify which code needs to be available to glance mode. If your application is small, you can probably get away without the annotation at all, but at some point you'll start running low on memory. This is covered in the documentation.

    Note that you can also use resources (strings/layouts/json/...) from within a glance process. This requires you to add the scope attribute to the resource definition as described in the documentation as well.

  • I noticed on the Garmin Weather widget glance view that the weather icon changes depending on the current weather. Is the changing of icons in a glance view only available to native widgets?