Deploy Widget
Integrating widgets with devices
Contents
1. Deploying widgets
2. Managing widgets on mobile devices
Integrating widgets with devices
You deliver widgets to users for deployment on S60 mobile devices in several ways. The most suitable method depends on your business plans. If you distribute widgets on your Web site, users can either download the widget directly to mobile devices or first download them to a PC and then install them on mobile devices.
Deploying widgets
Managing widgets on mobile devices ? Nokia 2009.
1. Deploying widgets
The following table lists the methods that are supported for deploying widgets on mobile devices:
The Web Runtime (WRT) environment includes a component that is able to detect when the user activates a widget for installation. It recognizes the file as a widget based on the file extension and MIME type. Therefore, if you decide to provide widgets on your Web site for download, you need to do the following to enable successful download and installation on mobile devices:
Table: Widget deployment methods Deployment method Deployment location on the
device Installation method Transfer via Bluetooth, email or other communication method
Inbox folder of the Messaging application
Using the Messaging application. Transfer using a USB cable
Phone memory Using the File Manager (File mgr.) application. Transfer via a memory card
Memory card Using the File Manager (File mgr.) application. Transfer using the Web
Browser for S60 If the MIME type is specified correctly for the widget package,
the installation will be completed
automatically. See the instructions
below.
1.Provide a URL to the widget on the Web site.
2.Specify the MIME type of the widget installation package in the HTTP response header. The
MIME type must be application/x-nokia-widget.
The following is an example of how to define the widget MIME type for an Apache server
configuration file:
AddType x-nokia-widget .wgz
Widgets do not need to be signed (for example, Symbian Signed) before deploying them on a mobile device.
? Nokia 2009.
2. Managing widgets on mobile devices
Managing widgets on a mobile device is very straightforward, as most of the management is performed automatically by the S60 platform and the Web Runtime (WRT) environment. Managing a widget means handling its general cooperation with the platform and other applications on the device, including:
Launching a widget
Moving a widget to the background or foreground
Exiting a widget
Creating a self-updating widget
Launching a widget
When you implement the widget deployment correctly, a widget can be installed successfully on a mobile device. Once installed, the widget is treated in many ways the same as any mobile application. First of all, it is automatically added to the S60 application menu. Users can launch the widget by navigating to it and opening it, or possibly by pressing a softkey. In addition to creating all the mandatory widget component files, with all the mandatory properties defined, no special registering is required to enable launching.
For more information on launching widgets, see section Introduction to widgets.
Moving a widget to the background/foreground
When a widget is running, it is automatically moved to the background if there is an incoming call, for example. If you launch an S60 mobile application from your widget, it appears in the foreground and the widget is moved to the background. When the application is closed, the widget returns to the foreground. The same happens when you launch a Web page from your widget. The Web page is accessed using the Web Browser for S60.
For more information on launching an application from a widget, see the openApplication() method in the Web Runtime API reference. For more information on launching a Web page, see the
openURL() method.
You can make your widget react in a certain way when it is moved to the foreground or to the background by using the onshow and onhide properties.
Exiting a widget
Users can exit a widget in several ways:
Right softkey
The right softkey is, by default, assigned to the "Exit" function, which terminates a running widget. So if you have not associated a new operation with the right softkey, your widget exits when the user presses this softkey.
Note: The control pane that shows the softkey labels is hidden by default in widgets. To have the softkey labels visible, use the showSoftkeys() method. To hide the softkey labels again, call hideSoftkeys().
Options menu
There is also an Exit option in the Options menu of every widget. This requires no
implementation in the widget code. For more information on the Options menu, see section Using softkeys and the JavaScript menu object in the Web Runtime API reference.
Figure: Exiting a widget using the Options menu
Call termination key
If users press the call termination key, the widget automatically exits. This functionality
requires no implementation in the widget code.
Figure: Call termination key
Creating self-updating widgets
In the JavaScript code of your widget, you can implement functionality that enables the widget to update itself without user action. Updates require a Web service or server from which the widget can query information on possible new widget versions.
To enable self-updating in a widget:
https://www.360docs.net/doc/dd10030076.html,e a variable for indicating the current version of the widget.
2.Send XMLHttpRequest to the Web server to query whether there is a new version of the
widget available.
The reply sent by the Web server should include a URL for the widget update.
https://www.360docs.net/doc/dd10030076.html,pare the server answer to the value of the current version variable.
4.If there is a newer version of the widget available on the server, launch the browser using the
URL of the new widget version.
When the new version of the widget has been downloaded to the mobile device, the S60
Software Installer receives the widget and installs it on top of the old version.
For an example of how to create a self-updating widget, see How to create self-updating WRT widgets available at Forum Nokia.
? Nokia 2009.