Pro Android Web Apps Develop for Android Using HTML5 CSS3 JavaScript 1st Edition Damon Oehlman pdf download
Pro Android Web Apps Develop for Android Using HTML5 CSS3 JavaScript 1st Edition Damon Oehlman pdf download
https://ebookultra.com/download/pro-android-web-apps-develop-for-
android-using-html5-css3-javascript-1st-edition-damon-oehlman/
https://ebookultra.com/download/beginning-android-web-apps-
development-1st-ed-edition-jon-westfall/
https://ebookultra.com/download/beginning-android-5th-edition-get-
started-building-apps-for-the-android-platform-grant-allen/
https://ebookultra.com/download/amazing-android-apps-for-dummies-1st-
edition-daniel-a-begun/
https://ebookultra.com/download/the-business-of-android-apps-
development-1st-edition-mark-rollins/
https://ebookultra.com/download/pro-web-gadgets-across-iphone-android-
windows-mac-igoogle-and-more-1st-edition-sterling-udell-auth/
Responsive Web Design with HTML5 and CSS3 2nd Edition Ben
Frain
https://ebookultra.com/download/responsive-web-design-with-html5-and-
css3-2nd-edition-ben-frain/
Pro Android Web Apps Develop for Android Using
HTML5 CSS3 JavaScript 1st Edition Damon Oehlman
Digital Instant Download
Author(s): Damon Oehlman, Sébastien Blanc (auth.)
ISBN(s): 9781430232773, 1430232773
Edition: 1
File Details: PDF, 10.94 MB
Year: 2011
Language: english
Pro Android Web Apps
Develop for Android Using
HTML5, CSS3 & JavaScript
■■■
Damon Oehlman
and
Sébastien Blanc
i
Pro Android Web Apps: Develop for Android Using HTML5, CSS3 & JavaScript
Copyright © 2011 by Damon Oehlman and Sébastien Blanc
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any
means, electronic or mechanical, including photocopying, recording, or by any information
storage or retrieval system, without the prior written permission of the copyright owner and the
publisher.
ISBN 978-1-4302-3276-6
ISBN 978-1-4302-3277-3 (eBook)
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos,
and images only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
President and Publisher: Paul Manning
Lead Editors: Steve Anglin and Douglas Pundick
Technical Reviewer: Kunal Mittal
Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell,
Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan
Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic
Shakeshaft, Matt Wade, Tom Welsh
Coordinating Editor: Mary Tobin
Copy Editor: Damon Larson
Compositor: MacPS, LLC
Indexer: BIM Indexing & Proofreading Services
Artist: April Milne
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring
Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
orders-ny@springer-sbm.com, or visit www.springeronline.com.
For information on translations, please e-mail rights@apress.com, or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or
promotional use. eBook versions and licenses are also available for most titles. For more
information, reference our Special Bulk Sales–eBook Licensing web page at
www.apress.com/info/bulksales.
The information in this book is distributed on an “as is” basis, without warranty. Although every
precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall
have any liability to any person or entity with respect to any loss or damage caused or alleged to
be caused directly or indirectly by the information contained in this work.
The source code for this book is available to readers at www.apress.com.
ii
Contents at a Glance
■Contents .......................................................................................................... v
■About the Authors ........................................................................................... x
■About the Technical Reviewer ........................................................................ xi
■Acknowledgments ......................................................................................... xii
■Introduction .................................................................................................. xiii
■Chapter 1: Getting Started ............................................................................... 1
■Chapter 2: Building a Mobile HTML Entry Form............................................. 21
■Chapter 3: HTML5 Storage APIs..................................................................... 47
■Chapter 4: Constructing a Multipage App ..................................................... 65
■Chapter 5: Synchronizing with the Cloud ...................................................... 95
■Chapter 6: Competing with Native Apps ...................................................... 111
■Chapter 7: Exploring Interactivity ............................................................... 129
■Chapter 8: Location-Based Services and Mobile Mapping .......................... 161
■Chapter 9: Native Bridging with PhoneGap ................................................. 193
■Chapter 10: Integrating with Social APIs .................................................... 221
■Chapter 11: Mobile UI Frameworks Compared ............................................ 255
■Chapter 12: Polishing and Packaging an App for Release .......................... 299
■Chapter 13: The Future of Mobile Computing .............................................. 337
■Appendix: Debugging Android Web Apps .................................................... 351
■Index ............................................................................................................ 359
iii
Contents
v
■ CONTENTS
viii
■ CONTENTS
ix
■ ACKNOWLEDGMENTS
x
■ CONTENTS
xi
■ ACKNOWLEDGMENTS
Acknowledgments
Firstly, my thanks go to my awesome wife and kids. 2010 was a massive year, filled with so many
opportunities, and you not only supported me with all the work I had to do, but also reminded
me that taking time to spend with family was just as important. I love you all so much.
Secondly, I want to thank the team at Apress for both the opportunity to write this book and
for the support and advice along the journey of writing it. I’ve certainly learned a great deal
through the process, and have appreciated your patience and professionalism from start to finish.
Damon
xii
■ CONTENTS
Introduction
As we move into a world where mobile devices are becoming the primary mechanism for people
to connect with the Internet, it should come as no surprise that the ability to develop applications
for mobile devices is becoming a sought after skill. We also have very strong vendor competition
in the space, resulting in a marketplace filled with a variety of devices.
We see vendors promoting development tools and marketplaces for their own devices,
attempting to create software ecosystems around their products. For the most part, the strategy is
working too (for some vendors more than others). Developers are using those tools and creating
“native” applications for a particular device, and then having to rebuild large portions of their
applications to target each different device.
For some companies building mobile applications, this is an acceptable approach. It is,
however, one that is entirely unsustainable for the longer term. Consider that each company with
a web product will be expected to provide both a desktop web application and suitable mobile
clients for multiple devices in the next few years (if not months). Then consider the number of
software developers - people like you and me, that there are in the world. Do we have the
required resources to meet this demand? I would venture not. There must be a better way. And
there is.
Building mobile web apps is this better way. It is an approach to mobile app development
that when done right, will have you rewriting a lot less code to target the variety of devices that
exist in the marketplace. This book focuses on writing mobile web apps for Android, but in reality
many of the concepts can be easily ported across to other mobile devices (which is the whole
point).
xiii
■ INTRODUCTION
JavaScript fundamentals book. We also make extensive use of the excellent jQuery JavaScript
library to make life generally easier during development. If that is something that is new to you,
we recommend having a jQuery tutorial or two handy as well. If you have experience with
Prototype, MooTools, or another of jQuery’s “competitors,” then you should be able to adapt the
sample code in the book with relative ease.
In terms of mobile web apps (and other JavaScript-rich web apps), learning how to structure
your applications for readability and maintainability is important. This is one of the reasons that
we have chosen to work through a couple of small application-sized projects in the book rather
than small code-snippets showing particular functionality. This will allow you to become familiar
with the different technical aspects of mobile web app development, and also gain an
understanding of how you might effectively put a real-world mobile web application together.
If you are already familiar with web application development, this book should make the
transition to mobile web app development simple. If, however, you are coming from a mobile
application development perspective, and are looking to explore the web app approach, having
those extra learning materials will make a big difference.
xiv
1
Chapter 1
Getting Started
Welcome to the wonderful world of web app development for Android. Over the course
of the book we will walk through the process of building mobile web apps. While
targeted primarily at Android, most (if not all) of the code will work just as well on
Chrome OS. Actually, the reusability of the application code will go beyond Chrome
OS—the code from this book should be able to run on any device that provides a
WebKit-based browser. If you aren’t familiar with WebKit or Chrome OS at this stage,
don’t worry—you will be by the end of the book.
In this chapter, we will go through a few topics at a high level so you can start building
applications as quickly as possible:
An overview of the platform capabilities of Android
Which of those capabilities we can access through the web browser
(either by default or by using bridging frameworks such as PhoneGap)
Configuring a development environment for coding the samples in this
book and your own applications
An overview of the tools that come with the Android development kit,
and some supporting tools to assist you in building web apps
1
2 CHAPTER 1: Getting Started
world can afford to do this, it can be difficult for a smaller organization or startup. Here
in lies the attraction of developing mobile web apps—write the application code once
and have it work on multiple devices.
This section of the book will outline the current features of the Android OS, and if
relevant whether you can access that functionality when building web applications.
For those who would prefer a summary of the system capabilities and what you can
actually access via the browser or a bridging framework, then head straight to Table 1–
2, toward the end of this section.
BRIDGING FRAMEWORKS
A bridging framework provides developers a technique for building web applications that can be deployed
to mobile devices. The framework also provides access to portions of the native device capabilities (such
as the accelerometer and camera) through a wrapper (usually JavaScript) to the native API.
During the course of the book, we will work through some examples that use PhoneGap
(http://phonegap.com) to bridge to some of this native functionality. While PhoneGap was one of the
first, there are many more bridging frameworks available. In this book, though, we focus on PhoneGap, as
it provides a simple and lightweight approach for wrapping a mobile web application for native
deployment.
For more information on the various mobile web app frameworks, I have written a couple of different blog
posts on the topic. In particular, the following post has some great comments from contributors on the
projects that help to show their areas of strength: http://distractable.net/coding/iphone-
android-web-application-frameworks.
While I would have loved to talk more about each in this book, the focus here is on building mobile web
applications. From my perspective, these are applications that can be deployed to the Web and accessed
via a device’s browser. The addition of a bridging framework should be an optional extra rather than a
requirement. Given this particular use case, PhoneGap is a clear winner.
Device Connectivity
While as consumers we are all probably starting to take the connectivity options of our
own mobile devices for granted, it’s important not to do this as a mobile developer (web
app or native). If mobile applications are built assuming that a connection to the Web is
always available, then this limits the usefulness of an application when connectivity is
limited—which is more often than you might think.
Understanding that your application will have varying levels of connectivity at different
times is very important for creating an application that gives a satisfying user experience
at all times.
In very simple terms, a mobile device can have three levels of connectivity from a web
perspective:
Random documents with unrelated
content Scribd suggests to you:
5.
Es war gar lieblich auf den Wassern, vorzüglich für einen, der in
so seltsamer Stimmung darüber hinfuhr, wie der schwedische Hirt
von der Lorena. Wenn es still am Ufer unter dem Fürberg war, so
war’s noch viel stiller auf der von der Nachmittagssonne beglänzten
Bucht von Bregenz, und der Korporal Sven hatte eine gute Fahrt. Er
saß und hielt die Hände vor dem Bauch gefaltet und ließ sein
Schifflein gleiten vor dem Winde. Wie jetzt das Ufer hinter ihm
versank, oder die Berge sich vielmehr heraushoben, so hob sich nun
auch vor ihm das niedrigere Hügelland des Allgäus, und vor allem
wie eine Stadt aus dem Wunderschatz der Frau Saga die freie
Reichsstadt Lindau.
Die grauen Mauern, deren Grund der römische Kaiser Tiberius
Claudius Nero legte, als er hier die Rhätier und Vindelicier besiegt
hatte, lagen noch stiller da als der See. Die alten Linden nickten
freundlich-schläfrig von den Bastionen, und die grün und silbern, rot
und goldfarbig glänzenden Turmdächer von Sankt Peter und der
heiligen Dreifaltigkeit — den Diebesturm nicht zu vergessen — luden
förmlich behaglich wie aus der Luft, so aus dem Wasser, den braven
Korporal Sven Knudson Knäckabröd zum Näherkommen ein. In dem
kleinen Hafen lagen ruhig, nur da und dorten von einem weißen
Spitzhund bewacht, die Lädinen und Halblädinen, die Segner und
Halbsegner und dazwischen die Lustgondeln der wohlhabenden
Reichsstädter, soweit sie sich nicht zu Bregenz befanden. Nur eine
Bürgerschildwacht war auf der Mauer zu erblicken, und die
schlummerte sanft auf ihre Partisane gestützt. Das Lebendigste auf
dem Wall zu Lindau im See waren um diese Stunde die Fliegen,
welche in Scharen über den erwärmten Geschützrohren summten.
Der Kahn des Schweden schoß, durch den Schatten der
Lastschiffe hin, in den Hafen hinein und an die Hafentreppe, und als
der Korporal sein Schifflein mit einem letzten Ruderschlag dort
antrieb, fragte ihn niemand um das Wohin und Woher, und das war
recht gut; denn im Augenblick hätte er vielleicht auf beides keine
Antwort zu geben gewußt. Seit dem Kolbenschlag am roten Egg war
ihm nicht so verworren zu Mute gewesen, aber trotz allem war ihm
heut’ doch die Welt behaglicher als damals, wo er sich auf dem
blutigen Strohlager am Schanktisch in der Taube zu besinnen suchte.
Doch wer auf eine solche Weise, wie er, im Hafen von Lindau
anlangte, der mochte, nachdem das Schifflein am Lande lag, wohl
selbst den Hut hin und wieder rücken um die Frage: Was nun? und
wohin nun? Der Korporal Sven stand und blickte an der nahen
Stadtmauer empor und durch den dunklen Bogen, welcher in das
Innere der Stadt führte, hindurch und rieb sich die Stirne. In dem
nämlichen Augenblick aber erschien über der Mauerbrüstung ein
dicker, roter, von schneeweißem Haar umflusterter Kopf, der sich
ächzend auf zwei gewaltige Fäuste legte und entsetzlich gähnend
auf den See hinausstarrte. Dasselbige Haupt spie verächtlich von der
Mauer der freien Reichsstadt hinab; ein nicht geringer Mund öffnete
sich, und — plötzlich — ganz unvermutet und von einer solchen
Erscheinung auch gar nicht zu vermuten, fing das Ding an zu singen,
und zwar eine Weise, welche im Munde des schwedischen Volkes
schon seit mehr denn hundertfünfzig Jahren umging.
Und in schwedischer Zunge sang das Unding auf der Mauer
heiser und gräßlich:
„Blitz und Donner! Alle guten Geister!“ stöhnte der Korporal Sven
Knudson Knäckabröd, versteinert nach dem Sänger aufstarrend;
doch der da oben gähnte noch einmal und scheußlicher als zuvor,
und fuhr fast noch unmelodischer fort:
und die Wirkung nach oben hinauf war nicht geringer, als die von
oben hinunter.
Auch der da oben schnellte empor und beugte sich über die
Brüstung und schrie:
„Bei der blauen Fahne Wasa’s, ist ein Spuck, ein Trold aus dem
See aufgestiegen, oder ist’s ein Landsmann? Ho Landsmann?
Landsmann!“
„Ho Landsmann!“ rief der Hirte von der Lorena; aber da er
einmal im Zuge war, so brüllte er weiter, daß die Bastionen der freien
Reichsstadt Lindau wie im Schrecken widerhallten:
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com