MOBILE

Programming the Mobile Web : Widgets and Offline Webapps - Platforms (part 3) - webOS & Android

2/12/2011 3:48:55 PM

3. webOS

The new webOS created by Palm (acquired by HP) is the first operating system where all possible native applications are developed using web technologies. Every application on a webOS device is created using HTML, CSS, and JavaScript, possibly with C and C++ plug-ins using the Plug-in Development Kit (PDK).

You can download the SDK, the PDK, and all the documentation from http://developer.palm.com. You’ll also find an Eclipse-based plug-in for code hinting and help in the design of these applications here.


Note:

webOS has the only web-based IDE solution for creating mobile applications. Ares (http://ares.palm.com/Ares/about.html) is a free mobile development environment with code support where you can visually design webOS applications.


A native web application for webOS is also called a Mojo application. Mojo is a JavaScript UI library based on the popular Dojo library that is generally used for creating webOS applications.

Every webOS application has a main HTML base file, an icon file, a configuration file (appinfo.json), a list of source files (sources.json), and an app folder with all the contents of each scene. A scene is a screen that shows information to the user, divided into an assistant (a JavaScript file for the behavior) and the view (an HTML file).

The appinfo.json file looks like this:

{
"id": "com.mystuff.hello",
"version": "1.0.0",
"vendor": "My Company",
"type": "web",
"main": "index.html",
"title": "Hello World",
"icon": "icon.png"
}

Every application is packaged in an .ipk file, created either with the Eclipse plug-in or using the palm-package command-line tool provided by the SDK.


Mojo allows JavaScript applications to have access to all the features of the phone using the Service APIs: Accelerometer, Accounts, Alarms, Application Manager, Audio, Browser, Calendar, Camera, Contacts, Document Viewers, Download Manager, Email, GPS, Maps, Messaging, People Picker, Photos, System Properties, Video, and more.

Note:

If you don’t like the Mojo framework, you can use other frameworks for the UI. There is even a PhoneGap implementation for Palm webOS with instructions available at http://wiki.phonegap.com.


The Mojo framework also includes many UI controls designed for optimal visualization in the operating system. You can use it using an empty div with the x-mojo-element attribute. For example:

<div x-mojo-element="ToggleButton" id="button"></div>

3.1. Distribution

You cannot serve an IPK package from your own website. The end-user devices can only install applications from a trusted source, such as the official store. To publish an application in the store, you will first need to apply for a Palm Developer Program account (free for open source projects and with a $99 fee for a full account).

Once you have an account, you can publish your applications to the App Catalog, the official webOS store. The applications can be distributed as free or premium content.

If you want to distribute an application from your own website instead, you can use the Web Distribution mechanism, which allows you to publish your IPK file without Palm review approval. You will receive a unique URL to give to users on your website to install the application. Again, the application can be distributed as either free or premium content, but there is no fee associated with this publishing method.

For premium content, you will receive 70% of the revenue generated by your application. You will be paid through PayPal. All the application links are offered as public RSS files to anyone that wants to integrate them in their websites.

3.2. HTML 5 applications

For the webOS browser, you can also create HTML 5 applications that the user can add as favorite websites without any Palm Developer Program subscription needed. These applications will not have access to the Mojo toolkit or the other advantages of full native applications. However, they will be able to use AppCache, offline storage, and possibly geolocation features.

Remember to use a short title for the webapp. You should encourage the user to add the webapp to the Launcher using WebPageAdd to Launcher. Unfortunately, webOS does allow us to define an icon; it will use the title and a little top-left corner screenshot of the website to identify it. You can insert an icon there to emulate icon definition. When the user has added your webapp, it will be available as an icon in the applications menu.


Warning:

There is no way to know if the user has already added the webapp to the Launcher, or if it was opened using that icon or the URL.


The user can also use the Bookmark feature, which displays a screenshot of the page as the icon.

4. Android

Android devices don’t yet have an iPhone-similar way to create full-screen webapps using only markup. So, for mobile widget development, we have two options:

  • Create an HTML 5 webapp that will finally open inside the browser.

  • Use a hybrid solution like PhoneGap.

4.1. HTML 5 webapp

Creating a webapp for Android devices is similar to creating one for Palm devices: you can develop an HTML 5 application that uses AppCache, offline storage, and maybe some Google Gears APIs, and the user can add it to the bookmarks. Once it’s been bookmarked, we can provide instructions to the user to add the application’s icon to the home screen. The instructions vary depending on the Android version. For Android 1.x devices:

  1. Add this page to bookmarks using MenuBookmarksAdd to Bookmark.

  2. Long press the new bookmark entry and select “Add shortcut to Home.”

For Android 2.X devices, like the Motorola Droid or Nexus One:

  1. Add this page to bookmarks using the bookmark icon (you can even provide a visual icon to the user) and select Add Bookmark.

  2. Long press the new bookmark entry and select “Add shortcut to Home.”

The home screen shortcut will use the icon specified in the apple-touch-icon-precomposed link tag as the first option for the high-quality icon or the favicon.


4.2. PhoneGap solution

If you want to use PhoneGap, you should download the package and download the Android SDK. In Eclipse (with the Android plug-in already installed), go to FileNew ProjectAndroid and point it to the android folder in the PhoneGap package.

Copy all your HTML, CSS, JavaScript, and image files to the android_asset folder (you can leave the demo files already in that folder or replace them).

Then, edit the /res/value/strings.xml file and change the value of the url field to file:///android_asset/index.html.

Build and test your application.


Note:

Android also supports home widgets as applications that run in the background and show their contents on the home screen, similar to the home screen widgets in Symbian. These are not web applications, but rather Android Java applications, available since version 1.5.


4.2.1. Distribution

You can distribute your PhoneGap Android application via your own website, serving the .apk file with the right MIME type: application/vnd.android.package-archive.

You can also distribute your application in the Android Market, the official store from Google. Other stores will be available soon, from other companies like Motorola.

You can apply for an Android Market account at http://market.android.com/publish; the initial fee is $25. You will be able to publish free applications from anywhere and premium applications if you are located in one of the available premium application countries (the U.S. and the UK, at the time of this writing). You will receive 70% of the revenue from your premium web applications.

You can also distribute your Android applications via Motorola’s official store, Shop4Apps. You can create a free publisher account at http://developer.motorola.com/shop4apps.

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
  •  
    Video
    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
    Collaborating Within an Exchange Server Environment Using Microsoft Office SharePoint Server 2007 : Exploring Basic MOSS Features
    Get A Faster, Safer PC (Part 3) - Make text easier to read, Disable a laptop touchpad
    Algorithms for Compiler Design: THE MACHINE MODEL
    iPhone, iPad touch and iPad : Realikety
    Storage, Screens And Sounds (Part 1)
    Audio Cleaning Lab MX - makes some sounds sound better
    SQL Server 2008 : Using Remote Stored Procedures
    Sony Xperia Go
    Web Security Testing : Manipulating Sessions - Analyzing Session Randomness with WebScarab
    Understanding the Basics of Collaboration in SharePoint 2010 : Microsoft Office Integration
    Buyer’s Guide - Keyboard and mice (Part 2) - Gigabyte Multimedia Ultra-slim Profile Keyboard GK-K6150, Microsoft Natural Ergonomic Keyboard 40000
    How To Store Your Files In The Ether
    Expert advice: Printer & Scanner (Part 2) - Samsung ML-2955DW
    SharePoint 2010 : PerformancePoint Services (part 2) - Using PerformancePoint
    SQL Server System and Database Administration : System Databases
    Is The Personal Blog Dead? (Part 2) - Going Mainstream
    Choosing The Right Gear For The Right Job
    Panasonic KX-MB1530CX Multi-Function Printer : A small workhorse for document printing
    Master Black-White Copying
    Windows 7 : Installing and Running Your Software (part 1)