Tải bản đầy đủ (.pdf) (433 trang)

javascript mobile application development saleh 2014 11 24 Lập trình Java

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.47 MB, 433 trang )

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

JavaScriptMobileApplication
Development

CuuDuongThanCong.com

/>

TableofContents
JavaScriptMobileApplicationDevelopment
Credits
AbouttheAuthor
AbouttheReviewers
www.PacktPub.com
Supportfiles,eBooks,discountoffers,andmore
Whysubscribe?
FreeaccessforPacktaccountholders
Preface
Whatthisbookcovers
Whatyouneedforthisbook
Whothisbookisfor
Conventions
Readerfeedback
Customersupport


Downloadingtheexamplecode
Errata
Piracy
Questions
1.AnIntroductiontoApacheCordova
WhatisApacheCordova?
Thedifferencesbetweenmobileweb,hybridmobile,andnativemobileapplications
WhyyoushoulduseCordova
Cordovaarchitecture
OverviewofCordovaAPIs
Summary
2.DevelopingYourFirstCordovaApplication
AnintroductiontoCordovaCLI
InstallingApacheCordova
CuuDuongThanCong.com

/>

GeneratingourSoundRecorder’sinitialcode
TheSoundRecorder’sinitialstructure
Aninsightintothewwwfiles
DevelopingSoundRecorderapplication
SoundRecorderfunctionality
SoundRecorderpreparation
SoundRecorderdetails
Recordingandplayingtheaudiofilesback
BuildingandrunningSoundRecorderapplication
Summary
3.ApacheCordovaDevelopmentTools
ConfiguringAndroiddevelopmentenvironment

ExtendingyourexistingEclipseIDE
CreatinganAndroidVirtualDevice
ImportingtheSoundRecorderapplicationintoEclipse
RunningtheSoundRecorderapplicationonarealAndroiddevice
ConfiguringiOSdevelopmentenvironment
ImportingtheSoundRecorderapplicationintoXcode
RunningtheSoundRecorderapplicationonarealiOSdevice
ConfiguringtheWindowsPhonedevelopmentenvironment
ImportingtheSoundRecorderapplicationintoVisualStudio
RunningtheSoundRecorderapplicationonarealWindowsPhone
Summary
4.CordovaAPIinAction
ExploringtheCordovaExhibitionapp
TheCordovaExhibitionappstructure
Accelerometer
Demo
TheHTMLpage
Viewcontroller
API

CuuDuongThanCong.com

/>

Camera
Demo
TheHTMLpage
Viewcontroller
API
Compass

Demo
TheHTMLpage
Viewcontroller
API
Connection
Demo
TheHTMLpage
Viewcontroller
API
Contacts
Demo
TheHTMLpage
Viewcontroller
API
Device
Demo
TheHTMLpage
Viewcontroller
API
Geolocation
Demo
TheHTMLpage
Viewcontroller
API
Globalization

CuuDuongThanCong.com

/>


Demo
TheHTMLpage
Viewcontroller
API
InAppBrowser
Demo
TheHTMLpage
Viewcontroller
API
Summary
5.DivingDeeperintotheCordovaAPI
Media,file,andcapture
Demo
TheHTMLpage
Viewcontroller
API
Notification
Demo
TheHTMLpage
Viewcontroller
API
Storage
Demo
TheHTMLpage
Viewcontroller
API
FinalizingtheCordovaExhibitionapp
Cordovaevents
Summary
6.DevelopingCustomCordovaPlugins

DevelopingacustomCordovaplugin

CuuDuongThanCong.com

/>

Usingplugman
Plugindefinition
Definingtheplugin’sJavaScriptinterface
DevelopingAndroidcode
DevelopingiOScode
DevelopingWindowsPhone8code
PublishingourplugintoCordovaRegistry
TestingourCordovaplugin
Summary
7.UnitTestingtheCordovaApp’sLogic
WhatisJasmine
ConfiguringJasmine
WritingyourfirstJasminetest
JasmineMatchers
Jasmineinaction–developingCordovaapptests
Anoverviewoftheweatherapplication
Developingsynchronouscodetests
Developingasynchronouscodetests
Manuallyexecutingtests
AutomatingtestsusingKarma
InstallingKarma
Karmaconfiguration
Runningtests(onmobiledevices)
GeneratingXMLJUnitandcodecoveragereports

IntegratingtestswiththeCItools
Summary
8.ApplyingitAll–theMegaApp
MegaAppspecification/wireframes
PreparingfortheMegaApp
TheMegaApparchitecture
TheMegaAppmodelandAPI

CuuDuongThanCong.com

/>

TheMegaAppuserinterface
FinalizingMegaApp
DeployingandrunningMegaApp
StartcontributingtoMegaApp
Summary
Index

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

JavaScriptMobileApplication
Development


CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

JavaScriptMobileApplication
Development
Copyright©2014PacktPublishing
Allrightsreserved.Nopartofthisbookmaybereproduced,storedinaretrievalsystem,
ortransmittedinanyformorbyanymeans,withoutthepriorwrittenpermissionofthe
publisher,exceptinthecaseofbriefquotationsembeddedincriticalarticlesorreviews.
Everyefforthasbeenmadeinthepreparationofthisbooktoensuretheaccuracyofthe
informationpresented.However,theinformationcontainedinthisbookissoldwithout
warranty,eitherexpressorimplied.Neithertheauthor,norPacktPublishing,andits
dealersanddistributorswillbeheldliableforanydamagescausedorallegedtobecaused
directlyorindirectlybythisbook.
PacktPublishinghasendeavoredtoprovidetrademarkinformationaboutallofthe
companiesandproductsmentionedinthisbookbytheappropriateuseofcapitals.
However,PacktPublishingcannotguaranteetheaccuracyofthisinformation.
Firstpublished:October2014
Productionreference:1161014
PublishedbyPacktPublishingLtd.
LiveryPlace
35LiveryStreet
BirminghamB32PB,UK.
ISBN978-1-78355-417-1
www.packtpub.com

CoverimagebyNehaRajappan(<>)

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

Credits
Author
HazemSaleh
Reviewers
Raymond,XieLiming
RanganadhParamkusam
JurisVecvanags
CommissioningEditor
AkramHussain
AcquisitionEditor
RichardHarvey
ContentDevelopmentEditor
MadhujaChaudhari
TechnicalEditor
ShashankDesai
CopyEditors
SayaneeMukherjee
KarunaNarayanan
ProjectCoordinator
RashiKhivansara

Proofreaders
SimranBhogal
MariaGould
AmeeshaGreen
PaulHindle
Indexer
HemanginiBari
Graphics
AbhinashSahu
ProductionCoordinator
AdoniaJones
CuuDuongThanCong.com

/>

CoverWork
AdoniaJones

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

AbouttheAuthor
HazemSalehhas10yearsofexperienceinJavaEE,mobile,andopensource
technologies.HehasworkedasatechnicalconsultantformanyclientsinEurope
(Sweden),NorthAmerica(USAandCanada),SouthAmerica(Peru),Africa(Egypt,

Morocco,andZambia),andAsia(Qatar,Kuwait,andKSA).HeisanApachecommitter
andapersonwhohasspentmanyyearsofhislifewritingopensourcesoftware.Besides
beingtheauthorofJavaScriptUnitTesting,PacktPublishing,andProJSFandHTML5:
BuildingRichInternetComponents,Apress,andtheco-authorofTheDefinitiveGuideto
ApacheMyFacesandFacelets,Apress,hehasalsoauthoredmanytechnicalarticles.Heis
alsoacontributingauthorrecognizedbydeveloperWorksandatechnicalspeakeratboth
localandinternationalconferencessuchasApacheConinNorthAmerica,GeeCon,
JSFDays,CONFESSinVienna,andJavaOneinSanFrancisco,Moscow,andShanghai.
HazemisnowworkingforIBMEgyptasanadvisorysoftwareengineer.Heisamember
oftheIBMMobileGlobalCenterofCompetency(CoC)andanIBMCertifiedExpertIT
specialist(L2).
Iwouldliketothankmywife,Naglaa,forsupportingmewhilewritingthisbook.Shehas
alwaysmotivatedmetocontinuethislongjourneyuntilitsend.Idefinitelydedicatethis
booktoherwithloveandpleasure.Iwouldalsoliketothankmywonderfulkids,Nada(4year-oldgirl)andAli(1-year-oldboy),foralwaysmakingmehappy.Iwouldliketothank
mymother,father,brother,andsisterforunderstandingwhyIwasnotavailableduring
manyweekendsasIwaswritingthisbook.AspecialthankstoeveryoneintheApache
Cordovacommunityformakingthedevelopmentofcross-platformmobileappsmuchless
painfulthanitcouldbe.Finally,Iwouldliketothankallthetechnicalreviewersand
editorsforimprovingthecontentofthisbook.

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

AbouttheReviewers
Raymond,XieLimingisasoftwareR&Dexpertwithexperienceofover16years

workinginmultipleITdomains,includingnetworking,multimediaIPcommunication,
insurance,telecom,andmobileapps/games.
RaymondholdsaMaster’sdegreeinSciencefromFudanUniversity.HeisalsoaPMIcertifiedProjectManagementProfessional.
HehasworkedasaseniormanagerforSoftfoundrySingapore,eBaoTech,andthe
EricssonShanghaiR&Dcenter,leadinganR&Dteamworkingonenterprise-andcarrierclasssoftware.InDecember2013,Raymondfoundedhisowncompany,RjFun
Technologies,thatfocusesonmobileapps/gamesandalsoproducesreusablecomponents
forthem.
HehasrichexperienceinR&Dmanagementandisalsoasoftwareexpertwithhands-on
architectinganddevelopmentskills.HeisveryactiveonGitHubandthe
Cordova/PhoneGapcommunity,wherehisnicknameis“floatinghotpot”.
Henowliveswithhiswife,Jenny,inShanghai,China.
RanganadhParamkusamholdsadegreeinComputerScienceandEngineering.He
beganhiscareerdevelopingcross-platformapplicationsforiOS,Android,andBlackBerry
usingPhoneGap,Sencha,andAngularJS.Hehasdevelopedmorethan30mobile
applications.HelaterstartedworkingwithnativecodesuchasiOSandJavatocreate
PhoneGappluginstobringthenativeUI/UXinhybridmobileapplications.
RanganadhdevelopedpluginsusingGoogle’sNativeClient(NaCl)andPortableNative
Client(PNaCl)togiveadesktopapplicationperformancetowebapplicationsandcreated
browserextensionsusingGoogleAPIsforGoogleChromeandFirefox.Hisworksinclude
aweb-basedimageeditor,texteditor(areplicaofAdobe’sBracketsapplication),webbasedimageeditorusingtheHTML5Canvaselementtoapplytheenhance,filter,resize,
andvariousothereffects,andchatapplicationusingNode.jsandMongoDB.Healso
createdanalgorithmthatsynthesizeswordsandgivesresponsesmadebystringpatterns,
whichmatchandaredevelopedusingPython.
RanganadhacquiredtheOracleCertifiedAssociate(OCA)certificatein2010andalso
certifiedforthePythonlanguagefromMITin2013.HewasawardedwithTechnoGeek
fortheyear2012-13andEmergingPerformeroftheyear2013-14forhisworks.
HeaimsatlinkingJavaScripttolow-andmedium-levellanguages,andheworkswiththe
C++,Python,Objective-C,andJavalanguages.Heiscurrentlyworkingasasenior
programmerintheCenterOfExcellence(COE)departmentinHiddenBrainsInfotech
Pvt.Ltd.,India.HeisactiveonGitHub,thePhoneGapcommunity,andstackoverflow.

Iwouldliketothankmyfamilyandfriendsfortheirsupportwhileworkingonallthis
stuff.
JurisVecvanagsstartedhiscareerintheITfieldintheearly’90s.Duringthistime,he
hadachancetoworkwithabroadrangeoftechnologiesandsharehisknowledgewith
CuuDuongThanCong.com

/>

Fortune500companiesaswellasprivateandgovernmentcustomers.
BeforemovingtoSiliconValley,hehadawell-establishedwebdesigncompanyin
Europe.HeiscurrentlyworkingasaseniorsolutionsengineerforSenchaInc.,helping
customerswritebetterappsbothfordesktopandemergingmobileplatforms.Whenit
comestowebtechnologies,hisinvaluableexperiencemakeshimatrustedadvisorand
competentreviewer.
Awayfromtheoffice,youwillfindhimspeakingatMeetupsintheSanFranciscoBay
areaandChicago.ThetopicsincludeNode.js,ExtJs,andSenchaTouch.Heispassionate
aboutbleeding-edgetechnologiesandeverythingrelatedtoJavaScript.
Iwouldliketothankmyfamilyfortheirconstantsupportwhileworkingonthisbook.

CuuDuongThanCong.com

/>

CuuDuongThanCong.com

/>

www.PacktPub.com

CuuDuongThanCong.com


/>

Supportfiles,eBooks,discountoffers,and
more
Forsupportfilesanddownloadsrelatedtoyourbook,pleasevisitwww.PacktPub.com.
DidyouknowthatPacktofferseBookversionsofeverybookpublished,withPDFand
ePubfilesavailable?YoucanupgradetotheeBookversionatwww.PacktPub.comandas
aprintbookcustomer,youareentitledtoadiscountontheeBookcopy.Getintouchwith
usat<>formoredetails.
Atwww.PacktPub.com,youcanalsoreadacollectionoffreetechnicalarticles,signup
forarangeoffreenewslettersandreceiveexclusivediscountsandoffersonPacktbooks
andeBooks.


DoyouneedinstantsolutionstoyourITquestions?PacktLibisPackt’sonlinedigital
booklibrary.Here,youcansearch,access,andreadPackt’sentirelibraryofbooks.

CuuDuongThanCong.com

/>

Whysubscribe?
FullysearchableacrosseverybookpublishedbyPackt
Copyandpaste,print,andbookmarkcontent
Ondemandandaccessibleviaawebbrowser

CuuDuongThanCong.com

/>


×