Class: Toybox.Application.AppBase
- Inherits:
-
Toybox.Lang.Object
Overview
AppBase is the base class for an app.
All apps inherit from this class and use it's methods to manage the life cycle of an app.
-
Your app overrides the class to provide entry points with the following methods:
-
These functions are called in the following order:
Every AppBase object has access to an object store to persist data.
Direct Known Subclasses
Application.AudioContentProviderApp
Constant Summary
-
GlanceTheme
Glance color themes for supported devices
Name | Value | Since | Description | See Also |
---|---|---|---|---|
GLANCE_THEME_DEFAULT | 0 | API Level 4.0.0 |
||
GLANCE_THEME_BLUE | 1 | API Level 4.0.0 |
||
GLANCE_THEME_GOLD | 2 | API Level 4.0.0 |
||
GLANCE_THEME_GREEN | 3 | API Level 4.0.0 |
||
GLANCE_THEME_LIGHT_BLUE | 4 | API Level 4.0.0 |
||
GLANCE_THEME_RED | 5 | API Level 4.0.0 |
||
GLANCE_THEME_WHITE | 6 | API Level 4.0.0 |
||
GLANCE_THEME_PURPLE | 7 | API Level 4.0.0 |
Instance Method Summary collapse
-
allowTrialMessage() as Lang.Boolean
Check if application trial messages are allowed.
-
clearProperties() as Void
deprecated
Clear the object store for the application.
-
deleteProperty(key as Application.PropertyKeyType) as Void
deprecated
Delete the given key from the object store.
-
getGlanceTheme() as AppBase.GlanceTheme
Method to get the glance theme.
-
getGlanceView() as [ WatchUi.GlanceView ] or [ WatchUi.GlanceView, WatchUi.GlanceViewDelegate ] or Null
Override to provide the WatchUi.GlanceView and WatchUi.GlanceViewDelegate for the glance preview.
-
getGoalView(goalType as Application.GoalType) as [ WatchUi.View ] or Null
Override to provide a WatchUi.View for a goal that has triggered within a watch face.
-
getInitialView() as [ WatchUi.Views ] or [ WatchUi.Views, WatchUi.InputDelegates ]
Override to provide the initial View and Input Delegate of the application.
-
getProperty(key as Application.PropertyKeyType) as Application.PropertyValueType
deprecated
Get the data associated with a given key from the object store.
-
getServiceDelegate() as [ System.ServiceDelegate ]
Get a ServiceDelegate to run background tasks for this app.
-
getSettingsView() as [ WatchUi.Views ] or [ WatchUi.Views, WatchUi.InputDelegates ] or Null
Override to provide the settings View and Input Delegate of the application.
-
getSyncDelegate() as Communications.SyncDelegate or Null
Get a SyncDelegate object that communicates sync status to the system for syncing content to the device.
-
getTrialDaysRemaining() as Lang.Number or Null
Override to return the number of days remaining in the trial If a developer wishes to implement time-based app trials, they will need to override this function to return the number of days remaining in the trial.
-
isActive() as Lang.Boolean
return true if app is currently in active state, otherwise false.
-
isTrial() as Lang.Boolean
Check if the application is in trial mode.
-
loadProperties() as Void
deprecated
Load the properties for the application.
-
onActive(state as Lang.Dictionary or Null) as Void
Invoked when app enters active mode, i.e.
-
onAppInstall() as Void
The callback method that is triggered in the background when the app is installed.
-
onAppUpdate() as Void
The callback method that is triggered in the background when the app is updated Requires the Background permission to be enabled and your application class to carry the :background annotation.
-
onAuthenticationRequest() as Void
Called when an Application requests to run code on demand, during an authentication process.
-
onBackgroundData(data as Application.PersistableType) as Void
Handle data passed from a ServiceDelegate to the application.
-
onDisplayModeChanged() as Void
The display mode has changed, only available in AMOLED or LCD screen products.
-
onEnhancedReadabilityModeChanged() as Void
The font mode has changed This method is called when the system changes to or from Enhanced Readability Mode.
-
onInactive(state as Lang.Dictionary or Null) as Void
Invoked when app enters inactive mode, i.e.
-
onNightModeChanged() as Void
The display mode has changed This method is called when the system changes to or from night mode.
-
onSettingsChanged() as Void
Called when the application settings have been changed by Garmin Connect Mobile (GCM) while while the app is running.
-
onStart(state as Lang.Dictionary or Null) as Void
Method called at startup to allow handling of app initialization.
-
onStop(state as Lang.Dictionary or Null) as Void
Override to handle application cleanup upon termination.
-
onStorageChanged() as Void
Called when Application storage is changed by the other running instance, of the app i.e Background Process while the CIQ app is running or vice-versa.
-
onValidateProperty(key as Lang.String, value as Application.PropertyValueType) as Lang.Boolean or Lang.String
Called when a property needs to be validated by the application.
-
openAppSettingsEditor() as Void
Function to open application settings editor.
-
saveProperties() as Void
deprecated
Save the properties for the application.
-
setProperty(key as Application.PropertyKeyType, value as Application.PropertyValueType) as Void
deprecated
Store the given data in the object.
-
validateProperty(key as Application.PropertyKeyType, value as Application.PropertyValueType) as Void
Validate a property being stored.
Instance Method Details
allowTrialMessage() as Lang.Boolean
Check if application trial messages are allowed.
Returns true
if the application should allow the product
to push unlock instruction pages for locked apps.
Returns true
by default.
clearProperties() as Void
This method may be removed after System 4.
Clear the object store for the application.
Background processes cannot clear properties.
deleteProperty(key as Application.PropertyKeyType) as Void
This method may be removed after System 4.
Delete the given key from the object store.
Background processes cannot delete properties.
getGlanceTheme() as AppBase.GlanceTheme
Method to get the glance theme.
getGlanceView() as [ WatchUi.GlanceView ] or [ WatchUi.GlanceView, WatchUi.GlanceViewDelegate ] or Null
Override to provide the WatchUi.GlanceView and WatchUi.GlanceViewDelegate for the glance preview.
getGoalView(goalType as Application.GoalType) as [ WatchUi.View ] or Null
Override to provide a WatchUi.View for a goal that has triggered within a watch face.
-
If a goal is reached when a watch face is running, this function will be triggered.
-
The type of goal that was met will be provided, and the AppBase should return a View that displays a goal reached message and/or animations for that goal.
-
If a View is returned from this function, the main watch face view will be shutdown, and then new View will pushed.
-
If this method is not overridden in the AppBase, or if it returns
null
, the native goal screens will be shown.
getInitialView() as [ WatchUi.Views ] or [ WatchUi.Views, WatchUi.InputDelegates ]
Override to provide the initial View and Input Delegate of the application.
This method must be overridden in derived classes. If called, this function will cause the application to crash.
getProperty(key as Application.PropertyKeyType) as Application.PropertyValueType
This method may be removed after System 4.
Get the data associated with a given key from the object store.
Properties must first be set with
setProperty() before they are
can be obtained with getProperty
.
Symbols can change from build to build and are not to be used for for Keys or Values.
getServiceDelegate() as [ System.ServiceDelegate ]
Get a ServiceDelegate to run background tasks for this app.
When a ServiceDelegate is retrieved, the following will occur:
-
The method triggered within the ServiceDelegate will be run
-
The background task will exit using Background.exit() or System.exit()
-
The background task will be automatically terminated after 30 seconds if it is not exited by these methods
getSettingsView() as [ WatchUi.Views ] or [ WatchUi.Views, WatchUi.InputDelegates ] or Null
Override to provide the settings View and Input Delegate of the application.
-
This function is only applicable to watch faces and data fields.
getSyncDelegate() as Communications.SyncDelegate or Null
Get a SyncDelegate object that communicates sync status to the system for syncing content to the device.
getTrialDaysRemaining() as Lang.Number or Null
Override to return the number of days remaining in the trial
If a developer wishes to implement time-based app trials, they
will need to override this function to return the number of days
remaining in the trial. This function will be called on app startup
to determine if a trial is active and push a notice to the user of
how many days remain in the trial. Note that if
allowTrialMessage()
is overridden to return false
, no notifications will be displayed.
isActive() as Lang.Boolean
return true if app is currently in active state, otherwise false.
isTrial() as Lang.Boolean
Check if the application is in trial mode.
This will always return true
for development
build apps. If the app has been signed by the store
it will return the current unlock state of the app.
This method should not be overridden or your trial mode functionality
could cease to function correctly.
loadProperties() as Void
This method may be removed after System 4.
Load the properties for the application
onActive(state as Lang.Dictionary or Null) as Void
Invoked when app enters active mode, i.e. occupying screen in the foreground.
onAppInstall() as Void
The callback method that is triggered in the background when the app is installed. Requires the Background permission to be enabled and your application class to carry the :background annotation.
onAppUpdate() as Void
The callback method that is triggered in the background when the app is updated Requires the Background permission to be enabled and your application class to carry the :background annotation.
onAuthenticationRequest() as Void
Called when an Application requests to run code on demand, during an authentication process.
onBackgroundData(data as Application.PersistableType) as Void
Handle data passed from a ServiceDelegate to the application.
When the Background process terminates, a data
payload may be available. If the main application is active when this
occurs, the data will be passed directly to the application's
onBackgroundData()
method. If the main application is not active,
the data will be saved until the next time the application is launched
and will be passed to the application after the
onStart() method completes.
onDisplayModeChanged() as Void
The display mode has changed, only available in AMOLED or LCD screen products.
This method is called when the system changes the display mode. Use the System.getDisplayMode() to get the current state.
onEnhancedReadabilityModeChanged() as Void
The font mode has changed
This method is called when the system changes to or from Enhanced Readability Mode. Use the Toybox::System::DeviceSettings#isEnhancedReadabilityModeEnabled field to get the current state.
onInactive(state as Lang.Dictionary or Null) as Void
Invoked when app enters inactive mode, i.e. hidden by system and not occupying screen. Access to certain system resources will be limited, such as GPS, ANT, Alerts (Vibs tones, flashlight).
onNightModeChanged() as Void
The display mode has changed
This method is called when the system changes to or from night mode. Use the Toybox::System::DeviceSettings#isNightModeEnabled field to get the current state.
onSettingsChanged() as Void
Called when the application settings have been changed by Garmin Connect Mobile (GCM) while while the app is running. Override this method to change app behavior when settings change. This is typically used to call for an update to the WatchUi.requestUpdate()
onStart(state as Lang.Dictionary or Null) as Void
Method called at startup to allow handling of app initialization.
Before the initial WatchUi.View is retrieved, onStart() is called. Application level settings can be initialized or retrieved from the object store before the initial View is created. This method must be overridden to handle your own app initialization.
the suspension state can be cleared in the event of reboot or app update.
onStop(state as Lang.Dictionary or Null) as Void
Override to handle application cleanup upon termination.
If the application needs to save data to the object store it should be done in this function. Once the function is complete, the application will terminate.
the suspension state can be cleared in the event of reboot or app update.
onStorageChanged() as Void
Called when Application storage is changed by the other running instance, of the app i.e Background Process while the CIQ app is running or vice-versa. Override this function to receive a callback when the storage is updated. Use this function to reload storage data from the application storage.
onValidateProperty(key as Lang.String, value as Application.PropertyValueType) as Lang.Boolean or Lang.String
Called when a property needs to be validated by the application.
openAppSettingsEditor() as Void
Function to open application settings editor
saveProperties() as Void
This method may be removed after System 4.
Save the properties for the application
setProperty(key as Application.PropertyKeyType, value as Application.PropertyValueType) as Void
This method may be removed after System 4.
Store the given data in the object.
Keys can be of the following types:
Values can be of the following types:
Array and Dictionary values may contain null
values or any of the above
listed types. There is a limit on the size of the Properties of 32 KB.
If this limit is reached, the properties will not be saved or reloaded.
Background processes cannot save properties.
Symbols can change from build to build and are not to be used for for Keys or Values.
validateProperty(key as Application.PropertyKeyType, value as Application.PropertyValueType) as Void
Validate a property being stored.