5. Windows Mobile
Microsoft added official support for widgets in Windows
Mobile 6.5. For Windows Mobile 5.X and 6.0, we can create hybrids using
PhoneGap or a simple web view .NET project.
Note:
Sony Ericsson offers the XPERIA Panels as a widget platform for
XPERIA devices with Windows
Mobile. You can download the SDK at http://www.mobilexweb.com/go/xperia.
12.3.5.1. Widgets
When creating widgets, you can download a Windows Mobile 6.5
emulator to test them. Windows Mobile widgets support the W3C widget
standard for packaging and configuration file support. So, we will use
the config.xml file and an icon
file, and we will zip all the content into a package with a .widget extension. The standard supports
localization for multiple language support and a JavaScript API for
platform access. The MSDN documentation is available at http://msdn.microsoft.com/en-us/library/dd721906.aspx.
ActiveX plug-ins such as Adobe Flash and Windows Media Player are also
supported.
Warning:
The widget can be used with touch navigation or using the
D-pad available on some devices. There is a bug in the D-pad
navigation, though, that forces us to add a tabindex attribute to every element that
we want to be focusable by the keys. Without this attribute, the
navigation will not work.
The global widget JavaScript
object allows us to read information from the config.xml file and access other useful
information, like the width,
height, and menu of the device. A systemState object is also available,
exposing properties like DisplayRotation (portrait or landscape),
PhoneRoaming, PhoneSignalStrength, and PhoneBatteryStrength.
We can use the widget.menu
object to create a menu and to assign it to one of the soft
keys:
// We create a menu with an ID for future identification
var option = widget.menu.createMenuItem(1001);
option.text = "Refresh";
option.onSelect = menuHandler;
// This assigns the menu to the soft key
widget.menu.setSoftKey(option, menu.leftSoftKeyIndex);
// This assigns the menu option to the Menu submenu
Widget.menu.append(option);
function menuHandler(id) {
// Do something
}
Note:
Windows Mobile 6.5 supports native XMLHttpRequest, so in widgets you don’t
need to create ActiveX objects.
The persistent storage mechanism is the same as in Symbian WRT
widgets: we use widget.setPreferenceForKey and widget.preferenceForKey. There is a limit of
4,000 bytes per key. The widget
object also supports the onshow and
onhide events to be handled.
This platform doesn’t have any other API to access Platform
Services, but we can create an ActiveX plug-in if we want to use it.
In fact, the BONDI team has developed an ActiveX alpha plug-in that
enables the use of BONDI features on Mobile Internet Explorer.
Note:
Widget files allows cross-domain Ajax requests to any server.
The widget ID will be included in the User-Agent header, if you want to check on
your server that the connection was from your widget.
5.1.1. Distribution
Distribution of Windows Mobile widgets can be done through
Windows Marketplace for Mobile, the official online store for
Microsoft. You can apply for a Marketplace publisher account at
http://developer.windowsphone.com; there is a
fee of $99 per year cost, and a cost per application submission ($99
at the time of this writing).
The operating system doesn’t support Over-the-Air installation
and doesn’t detect the .widget
file as an installation package. However, Microsoft does provide
detailed information in the documentation about how to install
widgets, by copying the .widget
file and changing a Registry entry for automatic widget installation
using the wmwidgetinstaller.exe
application provided by the OS. I hope future updates of the
operating system will support a better way to install widgets
without the store.
5.2. Hybrid solutions
The other solution for creating a mobile web application for
Windows Mobile 5 or 6 is to use a hybrid approach. You can create a
full web view project or download PhoneGap.
To compile a .cab .NET
application for Windows Mobile, you need Visual Studio Professional.
Using PhoneGap is experimental at the time of this writing. You should
download the PhoneGap project and use the winmo folder to store your C# classes and
WebForm design. In the www
folder, you will put all the HTML, JavaScript, and resource
classes.
These solutions can be distributed as .cab files in any store or from your own
website.
6. BlackBerry
BlackBerry launched a new widget engine in 2009 as a
first-class citizen of the operating system, starting in Device Software
5.0. For older devices (and newer ones), you can also use a hybrid
PhoneGap solution.
You can download the BlackBerry Widget SDK,
including a packager, an emulator, and sample code, from http://blackberry.com/developers/widget free of
charge.
The BlackBerry Packager (included in the SDK) creates the final
.cod file (the package) and an
.alx distribution file. You can
also download and use a free IDE for web development that will help in
the whole process (the BlackBerry Web Plug-in for Eclipse). The COD file
must be signed to be installed on a device.
A BlackBerry widget is a .zip
file containing a configuration file, an icon, an HTML file, and any
other resources that the widget uses. We can use Google Gears APIs
inside the widget, with the exception of LocalServer, which is not fully
supported. The BlackBerry Widget API can also be used to access some
resources and to install a widget on the user’s home screen. Some APIs
require signatures from a BlackBerry Signing Authority Tool.6.1. Widget API
The Widget API supports the features listed in Table 3, if they have previously
been defined in the permissions area of the configuration file (in the
feature tag). To this API we should
add Gears and the normal BlackBerry API browser extensions discussed
earlier.
Table 3. BlackBerry Widget API objects
Feature | Object | Allows us
to... |
---|
Application | blackberry.app | Access functions and
properties for the application, like the background and
foreground and home screen support |
File I/O | blackberry.io | Access to files and
directories |
Identity | blackberry.identity | Access user
identification information (IMEI, PIN, phone
number) |
Invoke | blackberry.invoke | Interact with other
installed applications |
Messaging | blackberry.messaging | Send
email |
PIM | blackberry.pim | Manage the Calendar,
Contacts, Tasks, and Memos |
Push | blackberry.push | Manage the listener for
information pushed from the server |
System | blackberry.system | Get and set system
information and event listeners |
User
Interface | blackberry.ui | Manage new JavaScript
dialogs and native menus |
Utility | blackberry.utils | Access useful utility
functions like blob converters or URL parsers |
For example, to add an item to the native menu, we should
use:
var item = new blackberry.ui.menu.MenuItem(false, 1, "Refresh", menuHandler);
blackberry.ui.menu.addMenuItem(item);
6.2. Configuration file
The configuration file is a config.xml file that follows the W3C widget
standard, with some additions. This file must have an access tag for each Internet domain that we
are going to contact using AJAX or some other resource request and a
feature tag for each API that we
are going to use:
<?xml version="1.0" encoding="utf-8" ?>
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="1.0.0">
<name>This is a widget</name>
<description>BlackBerry Widget</description>
<author href="http://www.mobilexweb.com" email = "yourname@email.com">
Maximiliano Firtman
</author>
<content src="index.html" />
<feature id="blackberry.system" />
<access url="http://mobilexweb.com" subdomains="true" />
</widget>
6.3. Distribution
You can distribute a widget just as you would any other Java
application (in fact, they are both .cod files). You can push it from the
BlackBerry Enterprise Server, you can make an offline installation,
you can serve the file from your server, or you can distribute it via
the official BlackBerry store, App World.
Note:
BlackBerry offers an Application Web Loader, which is an
Internet Explorer ActiveX plug-in that allows a website to deploy an
application or widget to a BlackBerry device from a desktop
computer.
To publish applications in App World, you’ll need to create an
account at http://na.blackberry.com/eng/developers/appworld.
Paying a $200 administrative fee will allow you to make 10 application
submissions (a new version counts as a new submission). When you reach
this limit, you can pay another $200 for 10 more submissions.
6.4. PhoneGap
The other solution for BlackBerry is to use a hybrid approach,
such as PhoneGap. This also works with some BlackBerry devices running
Device Software versions prior to 5.0. You’ll need to have the
BlackBerry JDE IDE installed and the PhoneGap package downloaded, and
then you can follow similar steps to those used with the other
platforms. You can find more information on the Community tab of the
PhoneGap site.
Note:
Motorola WebUI was a widget platform created by Motorola
before its Android movement. It was a great platform, but it is now
unofficially deprecated, with only two devices on the market. If you
want more information on this platform, see http://developer.motorola.com/platforms/webui.