Chapter 13. StageWebView

The Internet is becoming the town square for the global village of tomorrow.

Bill Gates

WebKit is a layout engine that browsers use to render web pages and to support interactivity and navigation history. Developed by Apple in 2002 and open sourced in 2005, WebKit is the default browser built in for Android.

The AIR runtime for the desktop also includes a version of WebKit built in. However, AIR for Android does not include it, and instead leverages the device’s native implementation and gives you access to some of its features via StageWebView.

StageWebView brings the benefits of an Internet browser to your own application. In this chapter, we will briefly discuss accessing the native browser, and then go over what StageWebView has to offer.

The Native Browser

To access the Internet, you need to set the permission for it:

<uses-permission android:name="android.permission.INTERNET" />

You can launch the Android native browser from an AIR application using the navigateToURL method. You pass a URL in the same way you do on AIR for the desktop:

function onPublicNews():void {
    navigateToURL(new URLRequest("http://www.npr.org"));
}

You can also use this method to launch native applications, such as the Android Market, that in turn makes calls to the Internet. The following example opens the Android Market and sets the criteria of applications to display as a URLRequest. Note that the protocol used is market:// instead of http://:

function onSearchMarket():void { navigateToURL(new ...

Get Developing Android Applications with Adobe AIR now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.