Preview: Google's tantalizing Mobile Chrome App SDK

Google's new Cordova-based toolchain lets you develop hybrid mobile apps from the same HTML, JavaScript, and CSS code as Chrome apps

1 2 3 4 Page 3
Page 3 of 4

If you think about what's being provided by the Chrome APIs listed above, you can see that some important capabilities are missing -- for example, access to the native device file system, access to the device's accelerometer and camera, playing and recording audio, and handling device events.

Fortunately, these capabilities are available, either from HTML5, or from the Cordova APIs, some of which are implemented as device-dependent Cordova plug-ins. The Cordova APIs include:

  • Accelerometer -- tap into the device's motion sensor
  • Camera -- take a photo using the device's camera
  • Capture -- access media files using the device's media capture applications
  • Compass -- obtain the direction that the device is pointing
  • Connection -- check the network state and cellular network information
  • Contacts -- work with the device's contacts database
  • Device -- gather device-specific information
  • Events -- hook into native events through JavaScript
  • File -- hook into the native file system through JavaScript
  • Geolocation -- make your application location aware
  • Globalization -- obtain information or perform operations specific to a locale and time zone
  • InAppBrowser -- launch URLs in another in-app browser instance
  • Media -- record and play back audio files
  • Notification -- generate visual, audible, and tactile device notifications
  • Splashscreen -- show and hide the application's splash screen
  • Storage -- hook into the device's native storage options

You'll notice that the Indexed Database API, aka IndexedDB, is not listed, either in the Chrome APIs or the Cordova APIs. That's because it is part of HTML5. Unfortunately, IndexedDB isn't yet supported in iOS Safari. There is a hack to implement IndexedDB over WebSQL that works on Safari, however.

From Chrome apps to mobile apps
The Mobile Chrome Apps development kit implements a command-line tool, cca (Cordova Chrome app), and supports the Android Development Tools (ADT 4.4.2 or higher) and Xcode 5, which in turn includes the Xcode command-line tools. You'll need Java JDK 7 and Apache Ant as well as the ADT for Android development, and both ios-deploy and ios-sim in addition to Xcode 5 for iOS development.

The cca tool is quite similar to the Cordova phonegap command-line tool. Like phonegap, cca can create a project in a directory, add or remove a plug-in, add or remove a platform, build a project, and run a project on a platform. In addition, cca can check its environment, copy an existing Chrome app project into a new Mobile Chrome project, and run a local Web server.

MobileChromeApps and Xcode
Figure 2: At the left, we see the source code for the "Hello, InfoWorld" Mobile Chrome App in the Xcode IDE; at the right, we see it in an iOS simulator. Note that after changing the Web source code you need to run the cca prepare command to generate updated mobile code before it can be reflected in the simulator.
1 2 3 4 Page 3
Page 3 of 4