Building Android Apps with HTML, CSS, and JavaScript
Jonathan Stark
Brian Jepson
Copyright 2012 Jonathan Stark
OReilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (.
Nutshell Handbook, the Nutshell Handbook logo, and the OReilly logo are registered trademarks of OReilly Media, Inc. Building Android Apps with HTML, CSS, and JavaScript , the image of a maleo, and related trade dress are trademarks of OReilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and OReilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
O'Reilly Media
Preface
Thanks to mobile phones, we have moved from virtually no one having access to information to virtually everyone having access to the vast resources of the Web. This is arguably the most important achievement of our generation. Despite its overarching importance, mobile computing is in its infancy. Technical, financial, and political forces have created platform fragmentation like never before, and its going to get worse before it gets better.
Developers who need to engage large and diverse groups of people are faced with a seemingly impossible challenge: How do we implement our mobile vision in a way that is feasible, affordable, and reaches the greatest number of participants? In many cases, the answer is web technologies. The combination of advances in HTML5 and mobile devices has created an environment in which even novice developers can build mobile apps that improve peoples lives on a global scale.
Googles Android operating system is a compelling addition to the mobile computing space. In true Google fashion, the platform is open, free, and highly interoperable. The development tools are full-featured and powerful, if a bit geeky, and run on a variety of platforms.
Carriers and handset manufacturers have jumped on the Android bandwagon. The market is beginning to flood with Android devices of all shapes and sizes. This is a double-edged sword for developers. On one hand, more devices mean a bigger market. On the other hand, more devices mean more fragmentation. As with the fragmentation in the general mobile market, fragmentation on Android can often be addressed by building apps with HTML, CSS, and JavaScript.
Im the first to admit that not all apps are a good fit for development with web technologies. That said, I see a lot of apps written with native code that could have just as easily been done with HTML. When speaking to developers who arent sure which approach to take, I say this:
If you can build your app with HTML, CSS, and JavaScript, you probably should.
Using open source, standards-based web technologies gives you the greatest flexibility, the broadest reach, and the lowest cost. You can easily release it as a web app, then debug and test it under load with thousands of real users. Once you are ready to rock, you can use PhoneGap to convert your web app to a native Android app, add a few device-specific features if you like, and submit to the Android Marketor offer it for download from your website. Sounds good, right?
Who Should Read This Book
includes some basic SQL code, so a passing familiarity with SQL syntax would be helpful but is not required.
What You Need to Use This Book
, where I explain how to convert your web app into a native app that you can submit to the Android Market.
Conventions Used in This Book
The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values determined by context.
Tip
This icon signifies a tip, suggestion, or general note.
Caution
This icon indicates a warning or caution.
Using Code Examples
This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless youre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from OReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your products documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: Building Android Apps with HTML, CSS, and JavaScript, 2nd edition by Jonathan Stark (OReilly). Copyright 2012 Jonathan Stark, 978-1-4493-1641-9.
.
Safari Books Online
Note
Safari Books Online is an on-demand digital library that lets you easily search over 7,500 technology and creative reference books and videos to find the answers you need quickly.
With a subscription, you can read any page and watch any video from our library online. Read books on your cell phone and mobile devices. Access new titles before they are available for print, and get exclusive access to manuscripts in development and post feedback for the authors. Copy and paste code samples, organize your favorites, download chapters, bookmark key sections, create notes, print out pages, and benefit from tons of other time-saving features.
OReilly Media has uploaded this book to the Safari Books Online service. To have full digital access to this book and others on similar topics from OReilly and other publishers, sign up for free at http://my.safaribooksonline.com.
How to Contact Us
Please address comments and questions concerning this book to the publisher:
OReilly Media, Inc. |
1005 Gravenstein Highway North |
Sebastopol, CA 95472 |
800-998-9938 (in the United States or Canada) |
707-829-0515 (international or local) |
707-829-0104 (fax) |
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at:
http://shop.oreilly.com/product/0636920022886.do |
To comment or ask technical questions about this book, send email to:
For more information about our books, conferences, Resource Centers, and the OReilly Network, see our website at: