O'Reilly logo

Building Android Apps with HTML, CSS, and JavaScript, 2nd Edition by Brian Jepson, Jonathan Stark

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Going Native

Our web app can now do many things that a native app can do: launch from the home screen, store data locally on the phone, and operate in offline mode. We’ve formatted it nicely for the device and set up native-looking animations to provide feedback and context to the user.

However, there are still two things that it cannot do: it can’t access the device features and hardware (e.g., geolocation, accelerometer, sound, and vibration) and it can’t be submitted to the Android Market. In this chapter, you will learn how to extend the reach of your web app beyond the normal confines of the browser using an open source project called PhoneGap.

Introduction to PhoneGap

The mobile landscape is littered with devices, platforms, and operating systems. If you are a web developer, you might be familiar with the agony of testing 10 or so browser versions across 10 or so operating system versions. Multiply that by 100 and you have mobile. There is simply no cost-effective way to develop and test across all of the possible combinations.

Enter PhoneGap. PhoneGap is an open source development tool created by Nitobi (http://www.nitobi.com/; now part of Adobe) that acts as a unified bridge between web apps and mobile device APIs. It consists of a native app project template for each of the major platforms, where each project is just a bare-bones web browser with heightened permissions. What this means in concrete terms is that PhoneGap makes it possible to access the accelerometer, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required