Pro Android Web Apps_ Develop for Android using HTML5, CSS3 and JavaScript [Oehlman & Blanc 2011-02-21].pdf
(
13735 KB
)
Pobierz
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-13 (pbk): 978-1-4302-3276-6
ISBN-13 (electronic): 978-1-4302-3277-3
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: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell,
Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie,
• • •••• •• • • ••••••••••••
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
■
Contents at a Glance....................................................................................... iv
■
About the Authors ........................................................................................... x
■
About the Technical Reviewer........................................................................ xi
■
Acknowledgments ......................................................................................... xii
■
Introduction .................................................................................................. xiii
■
Chapter 1: Getting Started ............................................................................... 1
Understanding Android Platform Capabilities ......................................................................................................... 1
Device Connectivity............................................................................................................................................ 2
Touch ................................................................................................................................................................. 3
Geolocation ........................................................................................................................................................ 3
Hardware Sensors ............................................................................................................................................. 4
Local Databases and Storage ............................................................................................................................ 5
Camera Support ................................................................................................................................................. 5
Messaging and Push Notifications..................................................................................................................... 5
WebKit Web Browser ......................................................................................................................................... 6
Process Management ........................................................................................................................................ 6
Android OS Feature Summary ........................................................................................................................... 7
Preparing the Development Environment ............................................................................................................... 8
Text Editors and Working Directories ................................................................................................................ 8
Web Server ........................................................................................................................................................ 9
Emulator .......................................................................................................................................................... 11
Hello World............................................................................................................................................................ 16
Summary .............................................................................................................................................................. 19
v
■
CONTENTS
■
Chapter 2: Building a Mobile HTML Entry Form............................................. 21
HTML for the Mobile Web ..................................................................................................................................... 21
Mobile-Ready Web Pages ................................................................................................................................ 21
Adding Form Elements..................................................................................................................................... 26
Adding Some Style................................................................................................................................................ 27
Form Styles with a Splash of CSS3.................................................................................................................. 30
Improving the Page Title Appearance .............................................................................................................. 33
Coding for Different Screen Sizes .................................................................................................................... 34
Handling Device Orientation Changes.............................................................................................................. 35
Adding Form Validation......................................................................................................................................... 39
Providing Feedback with Limited Screen Space ............................................................................................. 40
Summary .............................................................................................................................................................. 46
Chapter 3: HTML5 Storage APIs..................................................................... 47
The Web Storage API ............................................................................................................................................ 48
Saving Objects to Web Storage Using JSON .................................................................................................... 49
Local vs. Session Storage ................................................................................................................................ 54
The Web SQL Database......................................................................................................................................... 54
Saving To-Do List Items with a Client-Side Database ..................................................................................... 56
Database Versioning and Upgrades ................................................................................................................. 62
Summary .............................................................................................................................................................. 63
■
Chapter 4: Constructing a Multipage App ..................................................... 65
Single HTML File, Multiple App Pages .................................................................................................................. 65
Creating a View Manager................................................................................................................................. 68
Implementing View Actions ............................................................................................................................. 70
Building the Application’s Main Screen ................................................................................................................ 73
Tweaking ViewManager Functionality ............................................................................................................. 77
Home Screen Storage Requirements............................................................................................................... 78
Wiring Up the Home Screen............................................................................................................................. 82
Building the All Tasks Screen ............................................................................................................................... 85
Implementing the View Stack ............................................................................................................................... 91
Summary .............................................................................................................................................................. 94
■
Chapter 5: Synchronizing with the Cloud ...................................................... 95
Exploring Online Storage Options ......................................................................................................................... 95
Online Synchronization Store Requirements ................................................................................................... 96
Avoiding a Three-Tier Architecture .................................................................................................................. 96
User Authentication ......................................................................................................................................... 96
A JavaScript Synchronization Library .............................................................................................................. 97
Possible Synchronization Solutions ................................................................................................................. 97
Getting Started with Google App Engine............................................................................................................... 98
Deploying jsonengine Locally .......................................................................................................................... 99
Choosing a Suitable Synchronization Mode................................................................................................... 100
Sending Your Offline Data to jsonengine ....................................................................................................... 101
Updating the User Interface for Online Synchronization ..................................................................................... 103
Making a Desktop Interface ................................................................................................................................ 106
Querying a jsonengine Instance..................................................................................................................... 107
Deploying Your Application on the Cloud ....................................................................................................... 109
Summary ............................................................................................................................................................ 110
■
vi
Plik z chomika:
musli_com
Inne pliki z tego folderu:
100 Questions and Answers to Help You Land Your Dream Android Job_ or to Hire the Right Candidate! [López-Mañas 2015-07-19](1).pdf
(742 KB)
20 Recipes for Programming PhoneGap_ Cross-Platform Mobile Development for Android and iPhone [Munro 2012-04-06](1).pdf
(6551 KB)
50 Android Hacks [Sessa 2013-06-13](2).pdf
(10631 KB)
A Guide to Android for Seniors_ Introduction to Android Phones and Tablets [Hollinder 2015-04-02](1).pdf
(336 KB)
Advanced Android 4 Games [Silva 2011-12-19](1).pdf
(7341 KB)
Inne foldery tego chomika:
3D Design - Programming
ActionScript
Actionscript - Flash - Flex - Air
Ada
ADO
Zgłoś jeśli
naruszono regulamin