is there a way to check if an app was started by the glance view?

Hi,

i developed a widget (garmoticz) for my previous watch (fr630), but now i have a new watch (fr265) i noticed that it behaves like an app.

in the widget on the 630 it just shows a front screen, which says press a button (cause connectiq does not allow all widget functionality on the 1st screen). 

However for the fr265 is created a glance view and if you click the glance view, it now starts the "app". but basically there i could skip the 1st screen.

If it was just for myself i could skip the 1st screen, but i have a lot of users on old devices who really like the app/widget.

So for older watches i would need the extra screen in the widget. For newer watches i don't.

So my question is: Is there a way in the InitialView to detect if the app/widget was started by the glance view?  this way i can make the ideal flow for both cases in just one codebase! 

  • I have a few apps that depending on if they are started from a glance or not behave differently.  In initialize I set a flag based on how the app was started:

            fromGlance=false;
            var sSettings=Sys.getDeviceSettings();
            if(sSettings has :isGlanceModeEnabled) {
            	fromGlance=sSettings.isGlanceModeEnabled;
            }	

  • nice! exactly what i was looking for!! Tx!

  • TL;DR note that DeviceSettings.isGlanceModeEnabled can distinguish between the “widget” and “glance” case (as the OP requested), but it can’t distinguish between the “activity/app launcher” and “glance” case. So it’s not quite right to imply that isGlanceModeEnabled tells you whether the app was started from a glance or not.

    To be precise, DeviceSettings.isGlanceModeEnabled doesn’t signify whether your app was started from a glance, it signifies whether glance mode is enabled for the device. Note it’s only certain devices which aren’t too old or too new (such as Fenix 6) which both support glance mode and have the ability to turn it off (isGlanceModeEnabled could be true or false). Older devices don’t have glances (isGlanceModeEnabled doesn’t exist) and newer devices have glances without the ability to turn them off (isGlanceModeEnabled should always be true).

    Yes, for some intents and purposes, the value of isGlanceModeEnabled is somewhat equivalent to “app was started from a glance”. Namely, this is true when you only want to distinguish between the *widget* case and the *glance* case, as in the OP.

    Here’s a counter example where isGlanceModeEnabled doesn’t help.

    - I write a device app for newer devices such as 965

    - Newer devices have the “super app” concept where all CIQ device apps can be added either as a regular app (in the app/activity launcher) or a glance (provided a glance view is implemented)

    - I implement a glance view for that app, so my app can be added as a glance view

    - Now my app can be launched either from the app/activity launcher or from its glance

    - isGlanceModeEnabled is always true, regardless of how my app was launched

    In this case, isGlanceModeEnabled doesn’t help me distinguish between *regular app* case and the *glance* case. Why would I care? Maybe my glance has information that I don’t want to repeat in the first screen of the main app view, when the app was launched from a glance. Maybe there’s other behavior I want to be different, based on whether the app was started from a glance or not.

  • i implemented the above solutions and came to the same finding as you describe. Cause on my watch (a FR265) i can start the "widget" also as an "app" .

    I my use case it seems to be OK. The reason i made an initialview with limited functionality is that in a widget not all functionality is allowed on the first screen: e.g. up and down buttons don't work (because they scroll to the next or the previous widget). So i made an openingsscreen which basically just says: tap the screen (or hiet the enter key) to start. And then the next screen also up and down button are allowed. But if i start as an "app" these keys are also allowed

    So i see the following situations

    1 Watch without glance capability --> App should show openingsscreen (this works!)
    2 devices with the super app concept --> App should always start right away, skip openingsscreen (this works also!)
    3 devices which can enable/disable glance capability
        3A --> glance capability disabled --> app should is always started as widget and should start with openingscreen (this works also!)
        3B --> glance capability enabled --> i'm not sure: in simulator it seems to work, cause it always starts as glance. however: i do not know if on these watches there might also be an option to still start as widget:    

    So does anyone know for situation 3B: Are their garmin devices which have a settings to enable or disable glances, but can still show the normal widget when glances are enabled? Cause in this case it would go wrong....

  • In the sim with devices where glances can be on or off (the fr945 for example) under Settings, "Glace Launch Mode" can be set to start either with a glance or as a full screen widget.   There is a setting on the fr945 that allows for glance or not too.

    Here are screenshots from the sim and the 945 target with the two options.  It's an app that uses BLE, and without glances I don't want it to start scanning when the user scrolls through the widget loop, but to start scanning right away when opened from a glance

    On devices with "super-apps" like the 265, in the glace loop, you see the glance, and if the app is started from the app loop, it starts scanning right away.  That's how I want it to work.

  • I haven't played with widgets for a long time but some ideas:

    1. I guess you can know that you're in the glance view (i.e from the dc.getHeight() vs System.getDeviceSettings().screenHeight)

    2. maybe you can save the timestamp of the click action on the glance view, and when the app starts you can compare that timestamp with the current timestamp. If they are more than 5 seconds apart then the app wasn't opened from the glance

  • In the SDK, core topics file there is an example of how to check if an app was launched from the glance.

    https://developer.garmin.com/connect-iq/core-topics/application-and-system-modules/#launch

    you can check the state in the onStart function for the :launchedFromGlance object.  It if exists and is true, then the app was launched from the glance view, otherwise it was not.  The link above has an example or more detail in the onStart method in the API reference.

    https://developer.garmin.com/connect-iq/api-docs/Toybox/Application/AppBase.html#onStart-instance_function