Skip to Content
Supercharged JavaScript Graphics
book

Supercharged JavaScript Graphics

by Raffaele Cecco
July 2011
Intermediate to advanced content levelIntermediate to advanced
278 pages
7h 20m
English
O'Reilly Media, Inc.
Content preview from Supercharged JavaScript Graphics

Chapter 10. Creating Android Apps with PhoneGap

In the previous chapter, we developed a mobile-friendly web application using jQuery Mobile. In this chapter, we’ll convert the very same mobile application into a native Android mobile application using PhoneGap. At first glance, converting a humble JavaScript application into a native Android application seems like a miraculous metamorphosis: native Android apps are usually written in Java, Java is not JavaScript, and you can’t convert from one to the other. How does PhoneGap manage this? In fact, PhoneGap’s apparent magical abilities lie within the Android system itself. Android provides a facility called WebView that allows native applications to display regular web content. This includes the ability to execute JavaScript within the web content as normal.

One exciting feature of WebView is that it also allows interaction between a native Android application and the web content within the WebView. This is extremely useful, both for Android developers wanting to display and interact with web content within their applications and for web developers wanting to take advantage of Android device features like cameras and accelerometers. Essentially, PhoneGap is an Android application that uses a WebView for your web content, and also provides a JavaScript library for accessing some of the facilities of the Android device itself.

Other flavors of PhoneGap work in a similar way. For example, the Apple iPhone version of PhoneGap uses the iOS ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Graphics, Games, and Sound with JavaScript

Graphics, Games, and Sound with JavaScript

O'Reilly Media, Inc.
Third-Party JavaScript

Third-Party JavaScript

Anton Kovalyov, Ben Vinegar

Publisher Resources

ISBN: 9781449311162Errata Page