MOBILE

Programming the Mobile Web : Widgets and Offline Webapps - Platforms (part 4) - Windows Mobile & BlackBerry

2/12/2011 3:50:40 PM

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
FeatureObjectAllows us to...
Applicationblackberry.appAccess functions and properties for the application, like the background and foreground and home screen support
File I/Oblackberry.ioAccess to files and directories
Identityblackberry.identityAccess user identification information (IMEI, PIN, phone number)
Invokeblackberry.invokeInteract with other installed applications
Messagingblackberry.messagingSend email
PIMblackberry.pimManage the Calendar, Contacts, Tasks, and Memos
Pushblackberry.pushManage the listener for information pushed from the server
Systemblackberry.systemGet and set system information and event listeners
User Interfaceblackberry.uiManage new JavaScript dialogs and native menus
Utilityblackberry.utilsAccess 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.
Other  
  •  Programming the Mobile Web : Widgets and Offline Webapps - Standards
  •  Mobile Application Security : BlackBerry Security - Networking
  •  Mobile Application Security : BlackBerry Security - Local Data Storage
  •  Themes on Windows Phone 7 Devices (part 2) - Changing the Theme & Detecting the Currently Selected Theme
  •  Themes on Windows Phone 7 Devices (part 1) - Applying a Theme
  •  Programming the Mobile Web : Mobile Widget Platforms
  •  Programming the Mobile Web : Geolocation and Maps - Showing a Map
  •  Mobile Application Security - BlackBerry Security - Permissions and User Controls (part 2)
  •  Mobile Application Security - BlackBerry Security - Permissions and User Controls (part 1) - RIM Controlled APIs
  •  Windows Phone 7 Development : Working with Controls and Themes - Introducing the Metro Design System
  •  Windows Phone 7 Development : WebBrowser Control - Saving Web Pages Locally
  •  Programming the Mobile Web : Geolocation and Maps - Detecting the Location (part 3)
  •  Programming the Mobile Web : Geolocation and Maps - Detecting the Location (part 2) - Google Gears
  •  Programming the Mobile Web : Geolocation and Maps - Detecting the Location (part 1) - W3C Geolocation API
  •  Programming the Mobile Web : Geolocation and Maps - Location Techniques
  •  iPhone Programming : Table-View-Based Applications - Connecting the Controller to the Model
  •  Programming the Mobile Web : Mobilizing WordPress and Other CMSs
  •  Programming the Mobile Web : Server-Side Browser Detection and Content Delivery - Content Adaptation
  •  Programming the Mobile Web : Multimedia and Streaming
  •  Mobile Application Security : BlackBerry Security - Development and Security Testing
  •  
    Top 10
    Windows Server 2003 : Domain Name System - Command-Line Utilities
    Microsoft .NET : Design Principles and Patterns - From Principles to Patterns (part 2)
    Microsoft .NET : Design Principles and Patterns - From Principles to Patterns (part 1)
    Brother MFC-J4510DW - An Innovative All-In-One A3 Printer
    Computer Planet I7 Extreme Gaming PC
    All We Need To Know About Green Computing (Part 4)
    All We Need To Know About Green Computing (Part 3)
    All We Need To Know About Green Computing (Part 2)
    All We Need To Know About Green Computing (Part 1)
    Master Black-White Copying
    Most View
    Epic Moments in Sports (Part 1)
    iPhone 3D Programming : Blending and Augmented Reality - Blending Recipe
    HP X2301 : Micro Thin, Macro Sights
    Advanced ASP.NET : Understanding Caching
    Amateur Astronomy Applications (Part 1) - WorldWide Telescope, Stellarium
    How To Buy…SSD Drives (Part 2)
    Macro Marvel by Peiling Lee
    Under The Surface (Part 1)
    Microsoft .NET : Design Principles and Patterns - Object-Oriented Design (part 1) - Basic OOD Principles
    Hosting a Multi-Tenant Application on Windows Azure : Selecting a Single-Tenant or Multi-Tenant Architecture
    Google Nexus 4 - Features Of A High-End Smartphone For Half The Price
    Developing an SEO-Friendly Website: Content Delivery and Search Spider Control (part 2)
    SQL Server 2008 : Explaining Advanced Query Techniques - Managing Internationalization Considerations
    Frequently Asked Questions About UAC
    Windows Server 2008 : Harnessing the Power and Potential of FIM
    Parallel Programming with Microsoft .Net : Dynamic Task Parallelism - An Example
    Microsoft XNA Game Studio 3.0 : Displaying Images - Using Resources in a Game (part 3) - Sprite Drawing with SpriteBatch
    Windows Server 2003 : Active Directory - Understanding Operations Master Roles
    Windows 7 : Using Windows Defender (part 3) - Using Windows Defender Tools & Troubleshooting Windows Defender
    iOS 6 Beta Review (Part 1)