O'Reilly logo

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

Building Android Apps with HTML, CSS, and JavaScript

Book Description

If you know HTML, CSS, and JavaScript, you already have the tools you need to develop Android applications. This hands-on book shows you how to use these open source web standards to design and build apps that can be adapted for any Android device -- without having to use Java.

You'll learn how to create an Android-friendly web app on the platform of your choice, and then convert it to a native Android app with the free PhoneGap framework. Discover why device-agnostic mobile apps are the wave of the future, and start building apps that offer greater flexibility and a broader reach.

  • Learn the basics for making a web page look great on the Android web browser
  • Convert a website into a web application, complete with progress indicators and more
  • Add animation with jQTouch to make your web app look and feel like a native Android app
  • Take advantage of client-side data storage with apps that run even when the Android device is offline
  • Use PhoneGap to hook into advanced Android features -- including the accelerometer, geolocation, and alerts
  • Test and debug your app on the Web under load with real users, and then submit the finished product to the Android Market
This book received valuable community input through O'Reilly's Open Feedback Publishing System (OFPS). Learn more at http://labs.oreilly.com/ofps.html.

Table of Contents

  1. Dedication
  2. A Note Regarding Supplemental Files
  3. Preface
    1. Who Should Read This Book
    2. What You Need to Use This Book
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. How to Contact Us
    7. Acknowledgments
  4. 1. Getting Started
    1. Web Apps Versus Native Apps
      1. What Is a Web App?
      2. What Is a Native App?
      3. Pros and Cons
      4. Which Approach Is Right for You?
    2. Web Programming Crash Course
      1. Introduction to HTML
      2. Introduction to CSS
        1. Applying a stylesheet
      3. Introduction to JavaScript
  5. 2. Basic Styling
    1. Don’t Have a Website?
    2. First Steps
      1. Prepare a Separate Android Stylesheet
      2. Control the Page Scaling
    3. Adding the Android CSS
    4. Adding the Android Look and Feel
    5. Adding Basic Behavior with jQuery
    6. What You’ve Learned
  6. 3. Advanced Styling
    1. Adding a Touch of Ajax
    2. Traffic Cop
      1. Setting Up Some Content to Work With
      2. Routing Requests with JavaScript
    3. Simple Bells and Whistles
      1. Progress Indicator
      2. Setting the Page Title
      3. Handling Long Titles
      4. Automatic Scroll-to-Top
      5. Hijacking Local Links Only
      6. Roll Your Own Back Button
    4. Adding an Icon to the Home Screen
    5. What You’ve Learned
  7. 4. Animation
    1. With a Little Help from Our Friend
    2. Sliding Home
    3. Adding the Dates Panel
    4. Adding the Date Panel
    5. Adding the New Entry Panel
    6. Adding the Settings Panel
    7. Putting It All Together
    8. Customizing jQTouch
    9. What You’ve Learned
  8. 5. Client-Side Data Storage
    1. Web Storage
      1. Saving User Settings to Local Storage
      2. Saving the Selected Date to Session Storage
    2. Web SQL Database
      1. Creating a Database
      2. Inserting Rows
        1. Error handling
      3. Selecting Rows and Handling Result Sets
      4. Deleting Rows
    3. What You’ve Learned
    4. Web Database Error Code Reference
  9. 6. Going Offline
    1. The Basics of the Offline Application Cache
    2. Online Whitelist and Fallback Options
    3. Creating a Dynamic Manifest File
    4. Debugging
      1. The JavaScript Console
    5. What You’ve Learned
  10. 7. Going Native
    1. Introduction to PhoneGap
    2. Download the Android SDK
    3. Download PhoneGap
    4. Setting Up the Environment
    5. Create an Android Virtual Device
    6. Build KiloGap
    7. Installing KiloGap in the Emulator
      1. Using the Screen’s Full Height
      2. Customizing the App Icon
    8. Installing KiloGap on Your Phone
    9. Controlling the Phone with JavaScript
      1. Beep, Vibrate, and Alert
      2. Geolocation
      3. Accelerometer
    10. What You’ve Learned
  11. 8. Submitting Your App to the Android Market
    1. Preparing a Release Version of Your App
      1. Removing Debug Code
      2. Versioning Your App
      3. Signing Your App
    2. Uploading Your App to the Android Market
    3. Distributing Your App Directly
    4. Further Reading
  12. A. Detecting Browsers with WURFL
    1. Installation
    2. Configuration
    3. Testing wurfl-php
  13. Index
  14. About the Author
  15. Colophon
  16. Copyright