Crosswalk is an HTML5 application runtime based on a variety of open source projects. The Crosswalk web runtime APIs included in the Intel® XDK distribution of the Crosswalk runtime include many cutting-edge APIs under consideration for standardization by the W3C*, as well as the popular Apache Cordova* device APIs and the Intel® XDK APIs. In this article you will find a summary of some of the important APIs that are supported by the Crosswalk runtime on Android*.
Please note that the APIs listed in this article represent a small subset of the features supported by the Crosswalk runtime on Android distributed by the Intel XDK. A complete listing of the APIs supported by Crosswalk can be found on the Crosswalk Project site at: http://www.crosswalk-project.org.
The Intel XDK includes the Crosswalk runtime as a supported target of the cloud-based build service. You can build a Crosswalk application for ARM and x86-based platforms running Android 4.x (i.e., Crosswalk applications can only be built to run on Android 4.x devices). You do this by selecting Crosswalk as a target in the Intel XDK build tab; if selected, the Intel XDK build service will create an Android .apk file that can be installed and run on an Android 4.x device.
App Preview Crosswalk, an Intel XDK debug and profile tool, is based on the Crosswalk Project. Applications that are debugged and profiled using App Preview Crosswalk use the same APIs and provide similar performance to applications built using the Intel XDK build service's Crosswalk target. See the Intel XDK documentation pages for details regarding how to debug, profile and build a Crosswalk application for the Android platform.
The Crosswalk Project
At the heart of the Crosswalk web runtime is the Blink* rendering and layout engine. Blink provides the same HTML5 features and capabilities found in today's modern web ecosystem, such as WebGL* and Web Audio*. Crosswalk enables state-of-the-art HTML5-based applications that make the most of today's leading edge mobile devices.
The following sections highlight the Crosswalk for Android APIs that are key to bridging the gap between the capabilities of hybrid HTML5 apps and native mobile apps. The full list of Crosswalk APIs are presented on the Crosswalk Project web site.
Cordova Device APIs
NOTE: When you build a Crosswalk application using the Intel XDK the Cordova 3.x and Intel XDK APIs are also available for inclusion (the standard Crosswalk runtime API described on the crosswalk-project.org site does not include a reference to the Cordova or Intel XDK APIs). See the Apache Cordova web site for complete Cordova API documentation and the Intel XDK Namespace Cordova Plugin APIs.
Video and Audio
The HTML5 <audio> and <video> tags are a standard part of desktop web runtimes (browsers) and nearly all mobile runtimes. These tags are basic building blocks for many HTML5 multimedia applications. Using the associated APIs developers can access, control and manipulate timeline data and network states of the multimedia (audio/video) files.
NOTE: The Crosswalk HTML5 <video> implementation is hardware accelerated on IA (x86) mobile platforms.
The WebAudio API can be used to create, manipulate and mix low-latency audio streams. The primary use case is games and complex multimedia applications. Using the WebAudio API, games can incorporate rich, low-latency effects with multiple audio streams. Unlike the desktop, the WebAudio API is not supported on all mobile platforms.
NOTE: The Crosswalk runtime provides access to the WebAudio API on a mobile platform and, like the <video> tag, includes optimizations for IA (x86) mobile platforms.
NOTE: WebGL is a performance intensive API that benefits from optimization and fine-tuning for the best experience. Performance optimizations of the WebGL API on Crosswalk for Android are best in Crosswalk 10 and later versions. Your performance may vary depending on the manufacturer of your Android device.
A W3C API called MediaStreams (aka getUserMedia) gives developers access to camera and microphone hardware. The Crosswalk runtime implements this API natively, providing access to a rich API that is currently not available on most mobile devices. Using the MediaStreams API, developers can take pictures, show live camera previews and manipulate images for interesting and creative effect.
NOTE: A similar, but simpler, API exists in the Cordova and Intel XDK APIs. The MediaStreams API in Crosswalk is in addition to the Cordova and Intel XDK Camera APIs.
Many well known native applications use real-time communications (RTC) like Skype, Facebook and Google Hangouts. The WebRTC API provides web developers with access to real-time communication without requiring native code or plugins. Applications that can benefit from WebRTC include video conferencing, chat, peer-to-peer data sharing and more. Like WebGL, the WebRTC API is absent from most mobile platforms; however, the Crosswalk runtime does provide access to WebRTC on Android devices.
NOTE: WebRTC is a performance intensive API that benefits from optimization and fine-tuning for the best experience. Performance optimizations of the WebRTC API on Crosswalk for Android are currently in an early stage and will continue to improve as the Crosswalk Project matures.
Media queries are an important component of the HTML5 lingua franca. A key component of CSS3, media queries provide a way to implement multiple CSS layout rules so an application can adapt to multiple form-factors and dimensions. They represent a fundamental tool for the pursuit of responsive web design user interfaces.
A powerful complement to media queries under review by the W3C is the @viewport CSS rule. This rule provides a way to create pixel perfect apps, and can ease the transition of converting an existing web app designed for desktop to the mobile platform. The @viewport rule provides extensive ways to control the viewport by setting layout width, limiting pinch and zoom effects and improving touch performance. The Crosswalk runtime provides access to the @viewport rule for your HTML5 app layouts.
Tactile feedback can create a more immersive user experience when used with mobile devices. The Vibration API gives developers access to a device's vibration hardware, allowing for all kinds of feedback. For example, the Vibration API can be used to add tactile feedback to touch UI elements in your web application.
NOTE: A similar, but simpler, Notification API exists in the Cordova and Intel XDK APIs; the Vibration API in Crosswalk is in addition to these APIs.
You can store resources directly on the local file system of a device using the File API, which recently reached "last call" status within the W3C working group. This API, which is important for underlying platform integration, allows web applications access to the native file system. For example, the Camera API can be used to take a photo and, with the aid of the File API, the image can be stored in the device filesystem making it accessible for other native and web based applications.
NOTE: A similar File API exists as part of the Cordova API. The File API provided by the Crosswalk API is in addition to the Cordova API.
This API is particularly useful for saving resources (battery and data) when an app is not visible. Using the Page Visibility API a developer can detect and receive events indicating an app's visible state. Based on this information, the app can fine tune its behavior, such as stop the screen updates or reduce server communication when it is not visible.
Device Orientation and Acceleration
An implementation of the Device Orientation API under standardization by the W3C, the Orientation and Acceleration API provides access to accelerometer, gyroscope and compass data to applications. This data can enhance the gaming experience; for example, in a driving game the mobile device could be used as the steering wheel.
NOTE: Similar but not identical APIs exist as a part of the Cordova and Intel XDK APIs.
Sharing your device screen with an external display is an increasingly popular use case for users of mobile devices. Apple AirPlay* and Google Chromecast* are the most well known methods for screen sharing. Unfortunately, there is no standard interoperable means to share screens. The Presentation API is an Intel initiative to the W3C standards group. The aim is to create a W3C standard for device screen sharing.
NOTE: Crosswalk for Android implements an early version of the Presentation API specification.