Skip to content

Application Design

  • When Vobot Dock loads an application, it will verify that the application's entry file has the correct content. If a function or property is missing, the system will not recognize it as an application.

  • The entry file of the application should contain at least the following functions or properties:

  • NAME: The name of the application
  • on_start: life cycle function, that is, the start of program running
  • on_stop: life cycle function, that is, the end of program running
# The name of the application to be displayed on the menu
NAME = "Minimum App"

# A file path or data (bytes type) of the logo image for this app.
# If not specified, the default icon will be applied.
ICON = ""

async def on_stop():
    # User triggered to leave this app, all features should be deactivated
    print('on stop')

async def on_start():
    # User triggered to enter this app, all features should be activated
    print('on start')

Life cycle

  • Every application goes through a series of runtime phases, during which it runs functions called lifecycle hooks, giving developers the opportunity to run their own code at specific stages.

clife cycle diagram

Lifecycle Hook API

async on_start
    - User triggered to enter this App for the first time, or from STOPPED state, all features should be initialed
    - Then, this App becomes STARTED state

async on_stop
    - User triggered to leave this App. This App is no longer visible. all features should be deactivated
    - This App becomes STOPPED state

async on_boot(apm)
    - pam: You can read more information through  reference/application manager
    - Called right after system boot
    - Call 'system.xxx' for system level configurations, e.g. device id, temperature unit...

async on_create
    - Called right after this App first launching, or from SHUTDOWN state

async on_pause
    - Another activity comes into the foreground (e.g. a system notification dialog).
    - Usually, all features should be paused
    - Then, this App becomes PAUSED state

async on_resume
    - Resume (from PAUSED state) after another foreground activity ended
    - Or, called right after STARTED state
    - all features should be re-activated
    - Then, this App becomes ACTIVE state

async on_running_foreground
    - Once this App becomes ACTIVE, called by system approx. every 200ms
    - Use 'await app_mgr.exit()' to leave current App and return to homepage (Then this App will enter SHUTDOWN state)

async on_running_background
    - Once this App becomes PAUSED, called by system approx. every 1s
    - Once this App becomes STOPPED, called by system approx. every 30s

async on_destroy
    - When the App is in STOPPED/PAUSED state, the system may call this to destroy this App completely.
    - e.g. when the system is low on memory, it will destory some background Apps.
    - Then this App becomes SHUTDOWN state