faq how to write "observation" app or like alarm clock

I've written wf, df and time to app Slight smile

I need some quick help to not spend time on testing.

Short description, user:

-go to the app and choose form menu [start observation] (for example steps/hr etc or set alarm)

- go somewhere else (activity, wf)

- app should run in background an "observe" for some event from system or from app

question/answers

- when app is in foreground

-- is the same rules like in wf/df system call onUpdate/onPartialUpdate and burn in protection?

--is any system controls

--- like in std alarm clock app (list)

---time picker

---etc. or I should implement everything myself

- when in background

-- how to run code: should I start timer on app.onStop() to do something in background (quick tests show that app exits)

-- is it possible to show view/alarm/vibrate when event happens?

I don't have much time so If it big work I'd like to know before Slight smile

thx

  • Look at the samples for apps and widgets in the SDK.  Widgets and device apps don't have onPartialUpdate and other WF functionality.  In fact, in them onUpdate isn't called unless you set up a timer to do it or based it on things like onBackgroundData.

  • It sounds to me like you want to write a background service that can interact with things other than the main app (e.g. another activity or watchface), in the form of a notification.

    I don't think that's possible.

    As far as I can tell, the background service can react to a bunch of different events, but then the only action it can take is to send a message to the corresponding main/foreground app. It can't send an alert or notification.

    In other words, the background service can really only talk to the associated foreground app.

    (Please correct me if I'm wrong, Jim.)

    As far as standard controls go, there's a few things in https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi.html like Menu2 which is decent (when it works), generic Picker, ProgressBar, etc. Nothing too fancy, but there's a few things which can be extended. You can check the SDK examples for some of these.

    I think one gotcha is that Vivoactive doesn't have TextPicker (I'm not sure if this applies to all VAs or just the first one)

    EDIT: I checked the docs and it doesn't look any Vivoactives have TextPicker at all, unless the docs are incomplete.

  • - when in background

    -- how to run code: should I start timer on app.onStop() to do something in background (quick tests show that app exits)

    If you want your background service to run periodically, I think you would use registerForTemporalEvent()

    developer.garmin.com/.../Background.html

  • No, no. I don't want to write next wf (one enough Slight smile) and wf has a lot of limitation (no alarm, vibration etc.).

    background process is not good solution it can run every 5 minutes too long.

    My app should "run" in background and has to run some code. I can put timer in view, but what happen if app is not in foreground?

  • My app should "run" in background and has to run some code. I can put timer in view, but what happen if app is not in foreground?

    You can't run a CIQ app and an activity at the same time. If you exit your app it won't keep running in the background.

  • None of the va or venu devices have the text picker,

    The background can pass data to the main app by way of Background.Exit()/onBackgroundData, and can also request the main app be launched with requestApplicationWake.

  • so how run clock alarm or stop watch? yes there are system apps but it is mean that external developer can't writ such app?

  • I think you're not understanding a background service.  It can run no more often than every 5 minutes, can run 30 seconds at most, and has no view.

  • I wrote a stopwatch (widget and device app).

    The trick is that you save the start time (and laps) in application storage, so you can "resume" the app as if it never exited.

    But no, you can't write the kind of alarm clock that you want to write, as far as I know.

    CIQ doesn't have the kind of multitasking that you're thinking of.

  • I understand background service because I've implemented it in my wf.

    Ok, lets describe app again. user go to app, set [show birthday date for wife] [show birthday date for doughter].

    I have to show message in that particular  day in noon.