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. Copyright 6 Table of Contents 9 Preface 13 Who Should Read This Book 14 What You Need to Use This Book 14 Conventions Used in This Book 14 Using Code Examples 15 Safari® Books Online 15 How to Contact Us 16 Acknowledgments 16 Chapter 1. Getting Started 19 Web Apps Versus Native Apps 19 What Is a Web App? 19 What Is a Native App? 19 Pros and Cons 20 Which Approach Is Right for You? 20 Web Programming Crash Course 21 Introduction to HTML 21 Introduction to CSS 24 Applying a stylesheet 26 Introduction to JavaScript 27 Chapter 2. Basic Styling 31 Don’t Have a Website? 31 First Steps 32 Prepare a Separate Android Stylesheet 35 Control the Page Scaling 37 Adding the Android CSS 38 Adding the Android Look and Feel 41 Adding Basic Behavior with jQuery 43 What You’ve Learned 49 Chapter 3. Advanced Styling 51 Adding a Touch of Ajax 51 Traffic Cop 51 Setting Up Some Content to Work With 54 Routing Requests with JavaScript 54 Simple Bells and Whistles 56 Progress Indicator 56 Setting the Page Title 59 Handling Long Titles 61 Automatic Scroll-to-Top 62 Hijacking Local Links Only 63 Roll Your Own Back Button 64 Adding an Icon to the Home Screen 70 What You’ve Learned 71 Chapter 4. Animation 73 With a Little Help from Our Friend 73 Sliding Home 73 Adding the Dates Panel 76 Adding the Date Panel 78 Adding the New Entry Panel 80 Adding the Settings Panel 82 Putting It All Together 84 Customizing jQTouch 86 What You’ve Learned 88 Chapter 5. Client-Side Data Storage 89 Web Storage 89 Saving User Settings to Local Storage 90 Saving the Selected Date to Session Storage 93 Web SQL Database 94 Creating a Database 96 Inserting Rows 98 Error handling 100 Selecting Rows and Handling Result Sets 102 Deleting Rows 106 What You’ve Learned 109 Web Database Error Code Reference 109 Chapter 6. Going Offline 111 The Basics of the Offline Application Cache 111 Online Whitelist and Fallback Options 114 Creating a Dynamic Manifest File 117 Debugging 123 The JavaScript Console 124 What You’ve Learned 126 Chapter 7. Going Native 127 Introduction to PhoneGap 127 Download the Android SDK 128 Download PhoneGap 132 Setting Up the Environment 133 Create an Android Virtual Device 135 Build KiloGap 136 Installing KiloGap in the Emulator 140 Using the Screen’s Full Height 143 Customizing the App Icon 144 Installing KiloGap on Your Phone 145 Controlling the Phone with JavaScript 146 Beep, Vibrate, and Alert 146 Geolocation 150 Accelerometer 155 What You’ve Learned 158 Chapter 8. Submitting Your App to the Android Market 159 Preparing a Release Version of Your App 159 Removing Debug Code 159 Versioning Your App 160 Signing Your App 160 Uploading Your App to the Android Market 164 Distributing Your App Directly 165 Further Reading 166 Appendix. Detecting Browsers with WURFL 169 Installation 169 Configuration 170 Testing wurfl-php 171 Index 173 Copyright......Page 6 Table of Contents......Page 9 Preface......Page 13 Conventions Used in This Book......Page 14 Safari® Books Online......Page 15 Acknowledgments......Page 16 What Is a Native App?......Page 19 Which Approach Is Right for You?......Page 20 Introduction to HTML......Page 21 Introduction to CSS......Page 24 Applying a stylesheet......Page 26 Introduction to JavaScript......Page 27 Don’t Have a Website?......Page 31 First Steps......Page 32 Prepare a Separate Android Stylesheet......Page 35 Control the Page Scaling......Page 37 Adding the Android CSS......Page 38 Adding the Android Look and Feel......Page 41 Adding Basic Behavior with jQuery......Page 43 What You’ve Learned......Page 49 Traffic Cop......Page 51 Routing Requests with JavaScript......Page 54 Progress Indicator......Page 56 Setting the Page Title......Page 59 Handling Long Titles......Page 61 Automatic Scroll-to-Top......Page 62 Hijacking Local Links Only......Page 63 Roll Your Own Back Button......Page 64 Adding an Icon to the Home Screen......Page 70 What You’ve Learned......Page 71 Sliding Home......Page 73 Adding the Dates Panel......Page 76 Adding the Date Panel......Page 78 Adding the New Entry Panel......Page 80 Adding the Settings Panel......Page 82 Putting It All Together......Page 84 Customizing jQTouch......Page 86 What You’ve Learned......Page 88 Web Storage......Page 89 Saving User Settings to Local Storage......Page 90 Saving the Selected Date to Session Storage......Page 93 Web SQL Database......Page 94 Creating a Database......Page 96 Inserting Rows......Page 98 Error handling......Page 100 Selecting Rows and Handling Result Sets......Page 102 Deleting Rows......Page 106 Web Database Error Code Reference......Page 109 The Basics of the Offline Application Cache......Page 111 Online Whitelist and Fallback Options......Page 114 Creating a Dynamic Manifest File......Page 117 Debugging......Page 123 The JavaScript Console......Page 124 What You’ve Learned......Page 126 Introduction to PhoneGap......Page 127 Download the Android SDK......Page 128 Download PhoneGap......Page 132 Setting Up the Environment......Page 133 Create an Android Virtual Device......Page 135 Build KiloGap......Page 136 Installing KiloGap in the Emulator......Page 140 Using the Screen’s Full Height......Page 143 Customizing the App Icon......Page 144 Installing KiloGap on Your Phone......Page 145 Beep, Vibrate, and Alert......Page 146 Geolocation......Page 150 Accelerometer......Page 155 What You’ve Learned......Page 158 Removing Debug Code......Page 159 Signing Your App......Page 160 Uploading Your App to the Android Market......Page 164 Distributing Your App Directly......Page 165 Further Reading......Page 166 Installation......Page 169 Configuration......Page 170 Testing wurfl-php......Page 171 Index......Page 173 modifiedIf 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 browserConvert a website into a web application, complete with progress indicators and moreAdd animation with jQTouch to make your web app look and feel like a native Android appTake advantage of client-side data storage with apps that run even when the Android device is offlineUse PhoneGap to hook into advanced Android features -- including the accelerometer, geolocation, and alertsTest and debug your app on the Web under load with real users, and then submit the finished product to the Android MarketThis book received valuable community input through O'Reilly's Open Feedback Publishing System (OFPS). Learn more at http://labs.oreilly.com/ofps.html. If you know HTML, CSS, and JavaScript, you already have the tools you need to develop Android apps. With this book, you'll learn how to use these web technologies to design and build apps for any Android device, using the framework of your choice Presents instructions for creating Android applications with HTML, CSS, and JavaScript, with information on such topics as styling, animation, client-side data storage, using PhoneGap, and testing and debugging.