-
Notifications
You must be signed in to change notification settings - Fork 104
Using the configuration
The plugin provides a means of passing configuration details between the HTML/ Javascript front-end and the background service.
The contents of the configuration will depend greatly on the specific background service; for example a service which records GPS location may need accuracy information passed into the configuration, while a polling service may need to pass in specific keywords or URL. This page describes the mechanism of how to use the configuration logic for your own development.
- Create a JSON Object within the HTML/ Javascript front-end;
var config = { "Key" : "Value" };
- Call [setConfiguration] (setConfiguration) from the HTML/ Javascript front-end
- Receive the configuration object within the Java [setConfig] (setConfig) method
- Save the configuration details as appropriate. Note that it is recommended that the configuration values are stored to persistent storage so that if the background service is restarted then the configuration details can be retrieved.
Calling any method from the HTML/ Javascript front-end will return the [Returned JSON] (Returned-JSON) - within which the configuration is a property.
The configuration object is created by the Java [getConfig] (getConfig) method. Within the method, relevant configuration values should be retrieved from persistent storage and returned as a Java JSONObject.
- [Returned JSON] (Returned-JSON)
- [setConfiguration] (setConfiguration)
- [getConfig] (getConfig)
- [setConfig] (setConfig)