Before we dive in, I’d like to quickly establish the playing field. In this chapter, I’ll define key terms, compare the pros and cons of the two most common development approaches, and give a crash course on the three core web technologies used in this book.
First, I’d like to define what I mean by web app and native app and consider their pros and cons.
To me, a web app is basically a website that is specifically optimized for use on a smartphone. The site content can be anything from a standard small business brochure site to a mortgage calculator to a daily calorie tracker—the content is irrelevant. The defining characteristics of a web app are that the user interface (UI) is built with web standard technologies, it is available at a URL (public, private, or perhaps behind a login), and it is optimized for the characteristics of a mobile device. A web app is not installed on the phone, it is not available in the Android Market, and it is not written with Java.
In contrast, native apps are installed on the Android phone, they have access to the hardware (speakers, accelerometer, camera, etc.), and they are written with Java. The defining characteristic of a native app, however, is that it’s available in the Android Market—a feature that has captured the imagination of a horde of software entrepreneurs worldwide, myself included.
Different applications have different requirements. Some apps are a better fit with web technologies than others. Knowing the pros and cons of each approach will help you make a better decision about which path is appropriate for your situation.
Here are the pros of native app development:
Here are the cons of native app development:
Here’s where it gets exciting. The always-online nature of the Android phone creates an environment in which the lines between a web app and a native app get blurry. There are even some little-known features of the Android web browser (see Chapter 6) that allow you to take a web app offline if you want. What’s more, several third-party projects—of which PhoneGap is the most notable—are actively developing solutions that allow web developers to take a web app and package it as a native app for Android and other mobile platforms.
For me, this is the perfect blend. I can write in my preferred language, release a product as a pure web app (for Android and any other devices that have a modern browser), and use the same code base to create an enhanced native version that can access the device hardware and potentially be sold in the Android Market. This is a great way to create a “freemium” model for your app—allow free access to the web app and charge for the more feature-rich native version.
Get Building Android Apps with HTML, CSS, and JavaScript, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.