Background => Temporal Event

Hi guys,

I started to play around with background tasks. It is quite easy to use but there is one limitation I do not understand:

when a widget sets a temporal event to occur let's say in 1 minute (60 seconds), the event gets triggered also if the widget was closed, fine. Now if I start the widget again and try to setup the background task again I get the error message, that the temporal event cannot be created because the last one was created less than 5 minutes ago. I totally understand that this limitation is active when being inside an app/widget, but why is this limitation not resetted when I leave the app and open it again? Because in that case the user itself is the one who decides that he wants to again trigger this background task.

Thanks!

Bye
  • When you start a temporal event, it keeps running even when you leave the widget. The min time you can use is 5 minutes. Are you trying to delete the event when you exit the widget? What's the wording of the error, because if you try to register with less than 5mins as the time, you'll get a "minimum time is 5 mins" error.
  • When you start a temporal event, it keeps running even when you leave the widget. The min time you can use is 5 minutes. Are you trying to delete the event when you exit the widget? What's the wording of the error, because if you try to register with less than 5mins as the time, you'll get a "minimum time is 5 mins" error.


    This seems to not be true. I can register a temporal event that should occur after 10 seconds, it works. But then I am not able to register another temporal event for 5 minutes after the last one triggered. This is also what is stated in the SDK documentation.

    I have not tried to exit the background process when exiting the widget because at that point my test event was already triggered and I assumed there is no need to do this. Still it seems that the 5 minute limit is considered also after exiting the widget and open it again.

    Bye
  • So you are registering the event to run at a specific time and then switching to an interval? The interval is a minimum of every 5 minutes, but that should be 5 mins after it was last run, so this could be a bug - has the one for a specific time run before you try to register an interval?. But as you are running in a widget, you could get around it - skip the "run at specific time", and just run the same code in the foreground, and let the background take over after that. In DS Weather, I request the data in the main process if it doesn't have any, and just register a temporal for every 5 minutes so it will keep updating - the code executed by the background is also available in the foreground in that case.

    Are you looking to have the background always run right when you start the widget? You might be able to do something with deleteTemporalEvent() when the widget exits, but that kind of defeats the purpose of having a background process in a widget. But maybe try using it after you register for a specific time and it runs, and before you register for an interval. I've not tried it, myself.
  • Former Member
    Former Member over 7 years ago
    Applications can never run more than one Temporal event of any type within 5 minutes of the last one that ran for that application, no exceptions. The user's interaction with your widget does not change this restriction. Background events are generally intended to run when your application is closed. Widgets should have all the permissions that background processes do, and can run the code in question directly if the user brings the application to the foreground.
  • Applications can never run more than one Temporal event of any type within 5 minutes of the last one that ran for that application, no exceptions. The user's interaction with your widget does not change this restriction. Background events are generally intended to run when your application is closed. Widgets should have all the permissions that background processes do, and can run the code in question directly if the user brings the application to the foreground.


    Hm, ok.

    My use case: I would like to create a timer widget where a user can set up a timer value and start it. When the widget is closed I would like to set a background task that executes when the timer value finishes. This would work for the first time without issues. But now if the user would try to set up another timer in the next 5 minutes, the framework would prevent this because the last event occurred less then 5 minutes ago. This makes it impossible to create timers, which is a little bit disappointing... But your statement is, that there is not plan to change the limitation, right?

    Thanks!

    Bye
  • Former Member
    Former Member over 7 years ago
    The design does limit this use case, and there are not any plans to change the limitation at this time.

    The background timer sample in the SDK does this, but the timer is a non-configurable 5 mintue timer. This use case can work for timers that are at least 5 minutes long.
  • The design does limit this use case, and there are not any plans to change the limitation at this time.

    The background timer sample in the SDK does this, but the timer is a non-configurable 5 mintue timer. This use case can work for timers that are at least 5 minutes long.


    Ok, then there is no way to develop a timer app/widget for Garmin watches, which is a feature every 20$ watch has, bad luck...

    Thanks!

    Bye
  • Another thing to note, is a number of the CIQ 2.x watches (maybe all) have a built in countdown timer. On the f5/935 for example, Long press up, go down to clocks, and then select timer, with similar steps on the va-hr,. Once started you can do other things, and you'll be notified when the timer expires.
  • There are ways to implement a timer, just not one as a background event as often as you are describing. We have a whole module for timer events. Likely this will need to be implemented as an app. There are several apps that "count down" to trigger different events. Like a workout app. In theory, you could do a temporal event as a timer as well. You just can't "reset" the timer immediately which is admittedly not as convenient.

    -Coleman


    Hi Coleman,

    yes, I understand that. But the advantage of a "normal" timer is that you do not need to take care of staying in the timer view to get notified.

    I have asked Brian via PM about the exact reason the temporal events are allowed only every 5 minutes, as I completely understand that for watch faces but do not get why this is the case for widgets/apps. Maybe I get a clarification from him and finally understand the reason, let's see.

    But thanks for your statement!

    Another thing to note, is a number of the CIQ 2.x watches maybe all have a built in countdown timer. On the f5/935 for example, Long press up, go down to clocks, and then select timer, with similar steps on the va-hr,. Once started you can do other things, and you'll be notified when the timer expires.


    This might be the case, but the advantage of ConnectIQ is that we can build our own improved views for features that are already existing for the devices, so why not also an own timer view? :)

    Bye