作者:empty 页数:182 出版社:empty |
If you know HTML, CSS, and Java Seri pt, you already have thetools you need to develop Android applications.This hands-onhook shows you howto use these opensource web standards1o design and build apps that can be adapted for any Androiddevice—without having to leam Java.Youll learn howto create an Android-friendly webapp on theplatform of your choice, and then convert il to a native Androidapp with the freePhone Gap framework.Discover why device-agnostic mobile apps are the wave of the future, and startbuilding apps that offer greater flexibility and a broader reach.TOPICS INCLUDE:Learn the basics for making a webpage look great on thew Convert a website into a web application, complete withAdd animation with jQ Touch to make your webapp lookw Take advantage of client-side data storage with apps thatUse Phone Gap to hook into advanced Android features-
including the accelerometer, geolocation, and alertsm Test and debug your app on the Web under load withreal users, and then submit the finished product to theAndroid Market
This book received valuable community input through O'Reilly'sOpen Feedback Publishing System(OF PS) .Leam more at
Beijing·Cam bid ge·Fam ham·Koln·Sebastopol·TokyoBuing Android Apps wth HTML, CSS, and JavaScriptby Jonathan StarkCopy rghtO2010JonahanStark.All righi ste served.Prnt ed in the United States of America.Pub ished by OReilly Media, In e, 1005 Gravenstein Highway North, Sebastopol, CA 95472O'Relly books maybe purchased for educational, business, or sales promotional use.On linc editionsareas eavlbletormosttlestht.nysufanboksulinecem, For marc mtn mm at on, contact ourcoc porate/instituti anal sales department:(HO 0)998-993Borcorporateltoreill.com.Editor:Brian JepsonIndexer:Lucie HaskinsProduction Editor:Adam ZarembaCover Designer:Karen Moni gomeryCopyeditor:Amy ThomsonInte or Dei he:Davd Fu toProofreader:Kiel Van HomIllustrator:Robert RomanoPrnt ing Hitory:September 2010:First EditionNur shel Handbook, theN us hel Handbook logo, and the O'Reilly logo arete gite red trademarks ofO'Relly Media, Inc.Bril ding Android Apps with HTML, CSS, and Java Scrip r.the image of a male o, andrelated trade dress are sra de marks of OReilly Media, In eMany of the designations used by manufacturers and sellers to distinguish their pra ducts are claimed astrade marls.Where t has e designations appear in this book, and OReilly Media, Inc., was aware of atrademark dl aim, the designations have been pnn ted in caps or initial caps.While every pre ca uci on has been taken in the preparation of this book, the publi her and author assumenote sponsibility for errors or omissions, or for damages resulting trom the use of them formation con
PrefaceThanks to mobilephones, we have moved from virtually no one having access to in-formation to virtually everyone having access to the vast resources of the Web.This isarguably the most important achievement of our generation.Despite its overarchingimportance, mobile computing is in its infancy.Technical, financial, and political forceshave created platform fragment arion like never before, and it's going to ger worse beforeit getsbetter.Developers who need to c ngage large and diverse groups of people are faced with aseemingly impossible challenge:“How do we implement our mobile vision in awaythat is feasible, affordable, and reaches the greatest number of participants? In manycases.the answer is web technologies.The combination of advances in HTML 5 andmobile devices has created an env it onment in which even novice developers can buildmobile apps that improve people's lives on a global scaleGoogles Android operatingsystem is a compelling addition to the mobile computingspace.In true Google fashion, the platform is open, free, and highly interoperable.Thedevelopment tools are full featured and powerful, if abit geeky, and run on a varietyof platforms.Carner sand handset manufacturers have jumped on the Android bandwagon.Themarker is began ning to flood with Android devices of all shapes and sizes.This is adouble-edged sword for developers.On one hand, more devices means a bigger markerOn the other hand, more devices means more fragmentation.As with the fragmentationin the general mobile market, fragmentation on Android can often be addressed bybud ng apps wth HTML, CSS, and Java scr pTm the first to admit that not all apps area good fit for development with webtech-nologies.That said, I see alot of apps wnit ten with native code that could have just aseasily been done with HTML.When speaking to developers who are n't sure whichapproach to take, I say this:If you can build your app with HTML, CSS, and JavaScript, you probably shouldUsing opensource, standards-based we h technologies gives you the g realest flexi bli ythe broadest reach, and the lowest cost.You can easily release it as a webapp, thendebug and test it under load with thousands of real users.Once you are ready to rock,you can use Phone Gap to convert your webapp to a native Android app, add a fewdevice-specifc features if you lke, and submit to the Android Market or offer it fordownload from your website.Sounds guo d, ng ht?Who Should Read This BookTm going to assume you have some basic experience reading and wn ting HTML, CSSand Java Sc npt(Query in particular) .Chapter 5 includes some basic SQLcode, so apassing familiarity with SQL syntax would be helpful but is not required.What You Need to Use This BookThis book avoids the Android SDK wherever possible.All you need to follow alongwith the vast majority of examples is a texteditor and the most recent version of GoogleChrome(a cutting-ed gc webbrowser that's available for both Mac and Windows athttp://www.google.com/chrome) .You do need to have the Android SDK for the Phone-Gap material in Chapter 7, where l explain howto convert your webapp into a nativeapp that you can submit to the Android MarkerConventions Used in This Book
Prepare a Separate Android Stylesheet
Control the Page Scaling
Adding the Android CSS
Adding the Android Look and Feel
Adding Basic Behavior with j Query
What You'veLe a med
3.Advanced Styling.
Adding a Touch of Ajax
Traffic Cop
Se ring Up Some Content to Work With
Routing Requests with Java Scrip r
Simple Bells and Whistles
Progress Indicator
Ser ting the Page Title
Handling Long Tiles
Automatic Scroll-to-Top
Hijacking Local Links Only
Roll Your Own Back Button
Adding an Icon to the Home Screen
What You'veLe am ned
4.Animation.
With aL in le Help from Our Friend
Sliding Home
Adding the Dates Panel
Adding the Date Panel
Adding the New Entry Panel
Adding the Sec tings Panel
Putting It All Together
Customizing jQ Touch
What Y on'veLe a med
5.Client-Side Data Storage.
Web Storage
Saving UserSettings to Local Storage
Saving the Selected Date to Session Storage
Web SQL Database
Creating a Database
Inserting Rows
Selecting Rows and Handling ResultSets
Deleting Rows
What You've