Push View from a WatchFace

Former Member
Former Member
Hi everyone,

I'm a beginner and trying to implement a watchface.
I successfully implemented an api call to retrieve some data with makewebrequest after struggling a bit and my V1 is now looking good.

For my V2, I would like to push a new view depending on the data retrieved by my api call.

I tried to call the pushView() method but got a "Permission Required" while debugging in Eclipse.

In the same vein, I tried to start an Attention.vibrate() but also got the same "Permission Required". I already activated background and comm permissions (to make the web request) but I can't see permissions that would be related to my problem.

I'm sure I'm missing something big / obvious for you guys.

Thanks for your help,

Marc

  • A watchface can only have a single view and can't use Attention.

    For Attention, the API doc states it's only for Widgets, Data Fields and Device Apps. I'm sure it's noted someplace that multiple views can't be used in a WF, but can't find it right now.

    Instead of a different view, maybe use a different layout (if you use layouts) or just a flag for on update if you use direct dc calls.

    Another thing to consider is when the WF won't have data from the background. The WF starts, background runs, it's got data, but if the user moves to a widget and back, by default, the WF won't have data until the background runs again.

    So what you'll want to do is save the data to Application.Storage when the WF gets it.

    In that case, WF runs, get's data and saves it, and displays the data.
    User moves to a widget and back.
    WF uses the saved data from Application.Storage until the background runs again.

    You might want to have a timestamp on the saved data, as it could be old if the user hasn't run the WF for a couple days. So if the saved data is "stale", don't use it
  • Former Member
    Former Member over 6 years ago
    Thanks a lot Jim for the very detailed answer. Yes I confirm that I didn't see that WF could only have one view but now it makes a lot of sense.

    I was considering using storage so thanks for confirming that as well.

    I'll try with layouts. My first attempt in that direction was an oom but I'll retry properly I guess.

    Ideally what I was looking for was to change completely the display like when a goal is reached. If I'm correct in this case my watch vibrates but I guess it's reserved for the goalviews and nothing else right?

    Will an animation at least be possible as part of the new layout?

    Have a great week end Jim and all.

    Marc
  • I looked at Goal View when it was first introduced, but actually have never used it in a real app. Or do you mean the standard goal screen? That's the firmware.

    I think Animation is kind of tricky, as it can only be used if the watchface isn't in low power, if I recall. Again, I've not used it.

    Changing layouts can be done, or you can just use direct dc calls over the layout. I think that might be how hermo does the popup to restart the watch you see in this post :
    https://forums.garmin.com/forum/developers/connect-iq/connect-iq-showcase/1229771-tidalface?p=1243070#post1243070. He might also just be using direct dc calls for everything.

  • I didn't see that WF could only have one view but now it makes a lot of sense.

    This isn't necessarily true. I believe the limitation here is that you can't call WatchUi.pushView(), popView() and switchToView() from a watch face. If you create a single view that is passed off to the system (in getInitialView()), you can have that view draw different things either by changing the layout (as suggested by Jim), draw functions, or by delegating to another class.

    Ideally what I was looking for was to change completely the display like when a goal is reached.

    If you are using the goal system, you just need to return a new view from the AppBase.getGoalView() function. This view will be made active for a period of time and then it will be removed and the watch face view will be made active again.

    Will an animation at least be possible as part of the new layout?

    Yes, the device will switch to high frequency update mode while the goal view is visible. When the goal view is removed, the system will switch back to the normal update frequency. You can't use timers (the Timer.Timer class), you just have to take the updates at the rate that they come.

    Travis