Wearable Web

Service Application

This feature is supported in wearable applications only. The web service application is an optional feature, which means that it may not be supported in all wearable devices.

A service application is a type of Tizen Web application that provides an environment for running JavaScript in the background without a graphical user interface (the application follows the ECMA-262 specification). The service application is used to perform tasks which need to run periodically or continuously but do not require user interaction. For example, a service application can be used for getting data or listening to platform events in the background. As service applications do not have UI components, they run on top of a more light-weight runtime than UI applications. Therefore, you can expect them to perform better and consume less memory.

Service applications are packaged with a UI application. They can be launched by another application through the launch() and launchAppControl() functions of the Application API by using an explicit application ID. You can also register them to be launched automatically at boot time.

The device main menu does not contain any icons for service applications, because the applications run in the background. The task switcher does not show them either. Service applications can run simultaneously with other service and UI applications.

Note
The wearable service application requires partner-level certification in Tizen 2.3.

Fundamentals

You can use a selection of the following Tizen wearable Web Device APIs to interact with the platform or other service applications. More Device APIs for service applications are supported in the next release.

Table: Fundamental APIs
API Description
Tizen The base object for accessing the Tizen wearable Web Device APIs.
Alarm This API provides functions for setting and unsetting alarms.
Application This API provides information about the currently running and installed applications and ways to launch other applications.

Note that the getRequestedAppControl() function is only valid inside the onRequest() callback.

Package This API provides functions to install and uninstall Tizen packages and to get information about installed packages.
Filesystem This API provides functions to access the file system of a device and to read, write, copy, move, and delete files.
Message Port This API provides functions for an application to communicate with other applications.
Power This API provides interfaces and methods for controlling power resources.

Note that the isScreenOn(), restoreScreenBrightness(), turnScreenOn(), turnScreenOff(), setScreenBrightness(), and getScreenBrightness() functions are not supported for wearable Web service applications.

System Information This API provides information about the device's display, network, storage, and other capabilities.

Life-cycle

To make sure that you can run a service application, export a number of functions using the CommonJS Modules API. The functions need to be added to the module.exports object which is provided by the environment. These functions are called when there are life-cycle changes or application control events which are triggered by the application management framework.

Figure: State transitions

State transitions

  • onStart(): The entry point of the service. It is called after the service runtime finishes the set-up.
  • onRequest(): The listener for application control callbacks. It is provided to handle requests from other applications. You can understand the intention of the request and reply to it using the tizen.application.getCurrentApplication().getRequestedAppControl() function. This callback is also called when the application is first launched as an application launch is considered to be a request as well.
  • onExit(): This is called when the service ends. You can release resources or save the context by using this callback.

Package Management

Service applications are packaged with at least one UI application in a Web application package file. The Web application package file is installed, updated, and uninstalled as a single package, making the life-cycles of the service applications and the UI application synchronous.

When privileges are defined, their scope covers the entire package. Hence privileges do not have to be specified for service applications because they are packaged with at least 1 UI application in a Web application package file.

Configuration Extensions

To ensure that a service application is acknowledged by the platform, the config.xml file of the application must be extended.

Define the <tizen:service> element and check the configuration in the config.xml file.

The following is an example of a service application extension element:

<widget>
   <tizen:service id="[App_ID]" auto-restart="true" on-boot="true">
      <tizen:content src="[Start_JS_File]"/>
      <tizen:name>[App_Name]</tizen:name>
      <tizen:icon src="[App_Icon]"/>
      <tizen:description>[Description]</tizen:description>
   </tizen:service>
</widget>

<tizen:service> is a child element of the <widget> element in the config.xml file. With <tizen:service>, you can set the traits of a service application, such as application ID, auto restart, and boot launching capability. Under <tizen:service>, you can also set the starting script, the name, and the icon for the service application.

The definition of all service elements is listed and explained in the Extending Configuration Elements.

Required Feature

The following feature must be specified in the config.xml file if you want your Web application to be visible only on devices that support the Web Service Application:

<widget>
   <tizen:feature name="http://tizen.org/feature/web.service"/>
</widget>
Go to top