API: Displaying a message from a background app

Posted on
  • I'm writing an activity reminder (somewhat similarly to lazybones, but not implemented as a clock replacement). It's running as a background task (boot.js) and checks activity once an hour. If activity has been below a set threshold I need to display a full-screen message (and vibrate, that part I've got). How would I best do that? Can I use E.showMessage(), or will that end up corrupting parts of the display for the clock? Do I need to load() a separate JS-file that shows the full screen message? As an alternative I'm considering just using the framework from the messages app and simply triggering a pushMessage for that (though I'd prefer the app being able to display on its own, for flexibility).

  • You could use E.showAlert, or E.showPrompt if you want to customize your own buttons. I'm not sure what you mean by corrupting the display for the clock - once the user hits okay you can use something like load() to return the user to the watch face.

  • load() is quite CPU epensive? I try "draw()" in my widget, but it's no standard. It would be cool, if showAlert would make a copy of the old screen and restore that when the message closes. But I found no way to get the screen contents, yet.

  • You definitely want to load() a separate file to display your message, because otherwise the clock will draw all over it when the next minute arrives.

    Using the messages library seems like an interesting idea though. If that doesn't fit your purpose please post the problem, as I think ideally we want apps like yours to be able use that instead of all coming up with their own code to simply show a message.

  • Thanks for the replies!

    @rigrig that's exactly what I thought, since I'd be interfering with the clock thinking it has exclusive draw access.

    I'm leaning towards messages. If it's going to be used somewhat more generically then the ios and android libs will probably need some altering since they call .clearAll() on disconnect, to avoid the apps clearing each others messages.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

API: Displaying a message from a background app

Posted by Avatar for zerodogg @zerodogg