Probably a silly question, but I assume my datafield will only be executing if it's included in a layout of the currently running activity?
It won't be running if the current activity doesn't use it?
Thanks!
Probably a silly question, but I assume my datafield will only be executing if it's included in a layout of the currently running activity?
It won't be running if the current activity doesn't use it?
Thanks!
@jim_m_58 OP is not talking about a literal background process, just asking if their data field will somehow run if it's not added to the current activity.
I assume my datafield will…
Another point to consider is that on Edge devices, you don't have to open an activity profile to start it. The currently focused profile in the activity profile carousel is already running before you enter…
In theory it only should run when you're in the activity you added it to, except there's a bug (I can't find it in the forum...) : I have Hiker DF ciq datafield added to my Hike activity and when a device app that records a fit session with type Hike (Hiker App) records a session I can see in Garmin Connect that both recorded data to the fit file.
Once it's started, if you have it set to run the temporal event say every 5 minutes, it will keep running every 5 minutes until you delete the temporal event, so it can run long after the activity is stopped/saved.
If you don't have a background service, it stops running when you exit the activity.
What you can try is something like this, so the temporal evet is started and stopped.
function onTimerStart() { Background.registerForTemporalEvent(new Time.Duration(5 * 60)); } function onTimerStop() { Background.deleteTemporalEvent(); }
Thanks. It's a SimpleDataField, so are temporal events involved? (I haven't heard of those before sorry!)
@jim_m_58 OP is not talking about a literal background process, just asking if their data field will somehow run if it's not added to the current activity.
I assume my datafield will only be executing if it's included in a layout of the currently running activity?
Yes, that's how it's supposed to work.
As flocsy said, there have been known to be occurrences of a bug or bugs where a CIQ data field will run when it's not in the current activity. Not just the one that flocsy reported, but non-devs (end users) have reported a bug where a popular field like Stryd Zones will run (and record developer fields to the activity FIT field) even for activities where it's not added. (Note: pretty much the only way for users to know that a CIQ data field is running when it's not supposed to is by noticing that it's recording FIT fields to the activity.)
But that's not supposed to happen. If it does happen, it's safe to say that is a bug.
For further context, when a CIQ data field is added to an activity:
- onUpdate() will only be called when the CIQ data field is visible, roughly once per second
- compute() will be called whether or not the CIQ data field is visible, roughly once per second
. It's a SimpleDataField, so are temporal events involved? (I haven't heard of those before sorry!)
He's referring to a background service, which is a way for CIQ data fields (and other app types) to do certain things which would otherwise not be possible in the main app (using temporal events, which can run as frequently as once every 5 minutes) or to respond to certain events while the app isn't running (like the user reaching their steps goal).
(A termporal event is the mechanism by which a background service does "work", other than responding to predefined events)
As an example, one use case for a background temporal event in a CIQ data field is to communicate with the internet. Prior to CIQ 5, this was not possible in the foreground process of a CIQ data field, so a background service would be necessary to facilitate internet communication for CIQ data fields.
In the context of CIQ, when ppl talk about "background" or "backgrounding", they're almost always referring to a CIQ background service.
End users will sometimes talk about "running in the background" in a different context, such as being able to return to the watchface while a CIQ device app is running, without terminating the CIQ app. But this is not the way that "background" is "officially" used in CIQ.
Another point to consider is that on Edge devices, you don't have to open an activity profile to start it. The currently focused profile in the activity profile carousel is already running before you enter it. Therefore, compute()
is called for any data field in the selected activity profile as soon as the Edge device is switched on.
Thanks everyone, makes sense. Thanks!