What happens after app is closed

Posted on
  • I was hoping to understand abit more about what happens when you exit an app and return to the main screen and what role appID plays in functions like the one below, if any.

     1. @param {boolean} isOn - True if the GPS should be on, false if not
         * @param {any} appID - A string with the app's name in, used to ensure one app can't turn off something another app is using
         * @returns {boolean} Is the GPS on?
         * @url http://www.espruino.com/Reference#l_Bang­le_setGPSPower
         */
        static setGPSPower(isOn: ShortBoolean, appID: string): boolean;
    
    1. Is there an "onExit" type event you can subscribe to so can do things like saving app state before it closes?

    2. If I don't set the app id is it auto injected?

    3. How uptodate are the comments on functions like "setGPSPower"? I had assumed that once you exit an app to the main menu everything is reset to how it was before you opened the app. The comments kinda hint that multiple apps could be open at the same time. In what scenario would this happen? Widget?

    1. There is E.on('kill')
    2. No, providing an appID means "I need the GPS to stay on until I turn it off", omitting it means "Turn the GPS on now, until anything turns it off"
    3. Apart from the active app, widgets and/or boot apps could be using the GPS.
  • Thanks for the response. What situation would you want to turn on the gps and have something else turn it off? This is why I wondered if app id was legacy and was always being injected anyway. It means a widget could turn the gps off for my app without me knowing (not sure why they would...but they could).

    I also feel like widgets should be restricted to showing information and not changing any.

    If a boot app is managing power and says "no sorry you can't have gps on at moment" it can't switch it off until my app exits?

  • When you power on the GPS there is a tag argument that registers your app wanting the gps to stay on. At that point only your app can turn off the gps.

  • The idea is you mention your app/widget/code's name when you call setGPSPower - then Bangle.js keeps track and only turns the GPS off when no more apps need it.

    If you change apps (and fast load is off) then all that is lost and GPS is turned off automatically (if nothing in the new app says it needs GPS within 0.5s).

    How uptodate are the comments on functions like "setGPSPower"?

    Should be very up to date as they are produced from the code, but it's a big project and sometimes comments don't always get updated like they should

    I had assumed that once you exit an app to the main menu everything is reset to how it was before you opened the app.

    As above, yes, it is (unless you set your app up to support 'fast load' in which case it should actively turn stuff off on exit). But realistically you should forget about that for now - fast load only really makes sense for clock apps.

    The comments kinda hint that multiple apps could be open at the same time. In what scenario would this happen? Widget?

    Yes, exactly. Widgets, boot code, etc. The term app is a bit confusing there - it's basically any code that can be running

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

What happens after app is closed

Posted by Avatar for charlie @charlie

Actions