关闭

关闭

关闭

封号提示

内容

首页 [android.开发书籍].Practical.Android.Projects.pdf

[android.开发书籍].Practical.Android.Projects.pdf

[android.开发书籍].Practical.Androi…

上传者: appleflashstudio 2011-03-24 评分 0 0 0 0 0 0 暂无简介 简介 举报

简介:本文档为《[android.开发书籍].Practical.Android.Projectspdf》,可适用于IT/计算机领域,主题内容包含JordanGreylingPracticalAndroidProjectsCompanioneBookAvailablePracticalAndr符等。

JordanGreylingPracticalAndroidProjectsCompanioneBookAvailablePracticalAndroidProjectsTrim:xspine="pagecountppiBuildingcoolscripts,apps,andgamesforAndroidSmartphonesLucasJordan|PieterGreylingCOMPANIONeBOOKSEELASTPAGEFORDETAILSON$eBOOKVERSIONUS$ShelveinMobileComputingUserlevel:IntermediateAdvancedwwwapresscomSOURCECODEONLINEBOOKSFORPROFESSIONALSBYPROFESSIONALSISBNthisprintforcontentonlysizecolornotaccurateCYANMAGENTAYELLOWBLACKPANTONECSPOTMATTETakeapracticalapproachtobecomingaleadingedgeAndroiddeveloper,learningbyexamplewhilecombiningthemanytechnologiesneededtocreateasuccessful,uptodatewebappPracticalAndroidProjectsintroducestheAndroidSDKanddevelopmenttoolsofthetrade,andthendivesintobuildingcoollookingandfunappsthatputAndroid’samazingcapabilitiestoworkAndroidisthepowerful,fullfeatured,opensourcemobileplatformthatpowersphoneslikeGoogleNexus,MotorolaDroid,SamsungGalaxyS,andavarietyofHTCphonesandtabletcomputersThisbookhelpsyouquicklygetAndroidprojectsupandrunningwiththefreeandopensourceEclipse,NetBeans,andIntelliJIDEAIDEsThenyoubuildandextendmobileapplicationsusingtheAndroidSDK,Java,ScriptingLayerforAndroid,andlanguagessuchasPython,Ruby,JavascriptHTML,FlexAIR,andLuaInPracticalAndroidProjectsyou’llworkonrealworldprojectssuchas:•HostinganAndroidBASICinterpreter•ExtendingyourJavabasedAndroidapplicationswithembeddedLUA•ScriptingyourAndroiddevicewithSLA•AddingTwitterandFacebooktoyourapplications•UsingDgraphicsandanimationsforcasualgames•CreatingcrossplatformappswithJavaScriptHTMLandFlexwithAIRPracticalAndroidProjectsisforanydevelopernewtotheAndroidplatformwhowantstolearntobuildmobileapplicationsKnowledgeofthefundamentalsofJavaprogrammingisassumedISBNForyourconvenienceApresshasplacedsomeofthefrontmattermaterialaftertheindexPleaseusetheBookmarksandContentsataGlancelinkstoaccessthemDownloadfromWow!eBook<wwwwowebookcom>ivContentsataGlanceContentsvAbouttheAuthorsxAbouttheTechnicalReviewerxiAcknowledgmentsxiiPrefacexiiiChapter:AndroidFundamentalsChapter:DevelopmentToolsinPracticeChapter:RollYourOwnAndroidScriptingEnvironmentChapter:EmbeddingLuainAndroidApplicationsChapter:IntroducingSLA:TheScriptingLayerforAndroidChapter:CreatingaGUIwithHTMLJavaScriptandAIRChapter:UsingRESTwithFacebookandTwitterChapter:UsingtheGoogleAppEnginewithAndroidChapter:GameDevelopment:GraphicsChapter:GameDevelopment:AnimationChapter:AppInventorIndexChapterAndroidFundamentalsTheAndroidplatformisaveryexcitingyetrelativelynewplayerintoday’smobiledevicemarketBeyondratingveryhighlyinthenumberofcoolfeaturesperdevice,AndroidenabledsmartphonesarecurrentlyenjoyingthehighestpercentagesalesgrowthrateinthemobileindustryAccordingtoGartnerResearch,worldwidesalesofAndroidbasedsmartphonestoendusershavejumpedfromthenumberspotintonumberbytheendofthefirstquarterofThislevelofgrowthisexpectedtocontinueInfact,GartnerhaspredictedthatAndroidwillbecomethenumberworldwidemobileoperatingsysteminandwillchallengeSymbianforthenumberpositionbyWewanttosharewithyousomeoftheenthusiasmwehaveforthistrulyremarkabledevelopmentplatformThroughoutthecourseofthisbook,wewillattempttodothisbyshowingthewiderangeofopportunitiesavailableatyourfingertipswhenyouchoosetodevelopAndroidapplicationsPerhapsyouarereadingthisbookinordertogainmorebackgroundunderstandingoftheAndroidplatformPerhapsyouplantorollupyoursleevesandjoinusinrunningandplayingwiththeprojectsintheemulatororyourowndeviceWewanttogetyouupandrunningquicklyandprovideyouwithsufficientunderstandingoftheAndroidplatformandAndroidDevelopmentKit(ADK)developmentenvironmenttohavesuccesswithyourgoalsWiththosegoalsinmind,thischapteraimstobeaspracticalanintroductiontoAndroiddevelopmentaspossibleItalsostrivestocoverabroadspectrumofrequiredconceptualandtheoreticalbackgroundmaterialinaconciseandtothepointmannerWewillstartwithashortdescriptionoftheAndroidplatformandthenjumpstraightintocoverageoftheinstallationoftheAndroidSDKandsupportingdevelopmenttoolsTofullyroundoutourSDKsetupstudy,weembarkonastepbysteptestdrivethatFromGartnerpressrelease:http:wwwgartnercomitpagejspid=FromtheGartnerpressrelease:http:wwwgartnercomitpagejspid=CHAPTER:AndroidFundamentalsinvolvesgeneratingabarebonesAndroidprojectandgettingtheresultingskeletonAndroidapplicationupandrunningintheAndroidemulatorThenextorderofbusinesswillbeatouroftheAndroidplatformarchitectureHerewewilldescribetheAndroidplatformstackAndroidcomponentarchitectureandDalvik,theAndroidruntimeWiththisknowledgeinhand,wethencoverworkingwiththeJavaIDEsEclipse,NetBeans,andIntelliJIDEACommunityEditionplusspendsometimelearninghowtoequipthemwithAndroidprogrammingcapabilitiesviapluginsThismeanswehavealotofgroundtocover,solet'sgetstartedWhatIsAndroidInanutshell,AndroidisanoperatingsystemtargetedatmobilehardwaresuchasphonesandotherconstrainedcomputingdevicessuchasnetbooksandtabletcomputersTheconceptandplatformwasthebrainchildofAndroidInc,asmallstartupcompanyfromPaloAlto,California,thatwasacquiredbyGoogleinItsstatedgoalwastocreateasmall,stable,flexible,andeasilyupgradedoperatingsystemforhandsetsthatwouldbehighlyattractivefordevicemanufacturersandtelephonycarriersAndroidplatformreleasesxthroughxareaimedprimarilyatsmartphonedevices,whereasitisreportedthatAndroidreleasexwillbethefirstoperatingplatformspecificallydesignedwithhighendsupportfortabletcomputersTheAndroidplatformwasoriginallyunveiledinNovemberTheunveilingcoincidedwiththeannouncementoftheformationoftheOpenHandsetAlliance,agroupofcompaniesthatsharethegoalofpromotingopenstandardsformobiledeviceplatformssuchasAndroidInOctober,AndroidwasreleasedundertheApacheopensourcelicenseThisandtheflexiblecomponentbaseddesignoftheplatformpresentinnovativeandcosteffectiveopportunitiesformanufacturersandsoftwaredevelopersalikeWeaimtoshowcasesomeofthesedistinguishingplatformcapabilitiesduringthecourseofthisbookInstallingtheAndroidSDKWewillstartbyinstallingthecoreAndroidSDKandtoolsOuraimistogettheAndroidemulatorwithourownsimpleapplicationupandrunningonanAndroidVirtualDevice(AVD)assoonaspossibleTheexperiencegainedwillthenserveasabasisforfurtherdiscussionhttp:sourceandroidcomsourcelicenseshtmlCHAPTER:AndroidFundamentalsTheexamplesandcommandsyouwillbeshownwererunonamixtureofUbuntuGNULinux,MicrosoftWindows,andAppleMacOSXsystemsAllthetools,includingtheJDKandtheAndroidSDKtoolset,behaveinasimilar,ifnotidentical,manneracrossthemajorsupportedcomputingplatformsJavaDevelopmentKit(JDK)Tobeginwith,youshouldhavearecentversionoftheJavaSDK(JDK)installedonyourparticularsystemItcanbeobtainedeitherfromyouroperatingsystemdistributionpackageinstallmanagerapplicationordirectlydownloadedfromtheInternetWeassumethatwedonotneedtogointothedetailsfordoingthisSufficeittosaythatJDKorupwardshouldbefineThiswritingisbasedonJDKCHECKINGTHEJDKVERSION:ToconfirmthatacompatibleversionoftheJDKisinstalledandavailabletotheenvironment,weusuallydoaquickcheckonthecommandlineorconsoleterminal,asfollows:$java–versionjavaversion""OpenJDKRuntimeEnvironment(IcedTea)(bubuntu)OpenJDKServerVM(buildb,mixedmode)$javac–versionjavacIfsomethinggoeswrong,youshouldconsulttheJDKconfigurationdocumentationforyourparticularplatformWewillnotcoverdebuggingJavainstallationshereAndroidSDKandTargetPlatformsAssumingthatourJavaplatformisready,wenowneedtodownloadtheAndroidSDKstarterpackageanduseittoinstallourtargetAndroidplatformsTheAndroidSDKstarterpackagecanbedownloadedfromtheofficialGoogleAndroidSDKdownloadsiteSelectthedownloadappropriateforyourdevelopmentplatformThesupportedplatformscurrentlyincludeWindows,MacOSX(Intel),andLinux(i)InthecaseofhavingdownloadedanSDKstarterpackagearchiveforLinuxorMacOSX,unpackthedownloadedarchiveintoadirectoryofyourchoicehttps:jdkdevjavanethttp:developerandroidcomsdkCHAPTER:AndroidFundamentalsInthecaseofhavingdownloadedtheWindowsinstaller(exefile),runtheinstallerandinstallintoadirectoryofyourchoiceYoucouldcallthisdirectoryanythingyoulike,butwerecommendsomethingsimilartothefollowing:LinuxorMacOSXsystem:~androidsdklinuxxWindowssystem:C:androidsdkwindowsMakeanoteofthisdirectorypathnameforlateruseWithintherootoftheunpackeddirectorystructurethereshouldbeatextfilewithanamelikeSDKReadmetxtThishasspecificinstructionsforeachplatformWhatisimportanttonotehereisthatthedownloadedarchivedoesnotincludethecompleteSDKThefollowingnotecontainsanextractfromthereadmeshippedwiththelatestAndroidSDKasofthiswritingREADTHESDKREADME!TheAndroidSDKarchiveonlycontainsthetoolsItnolongercomespopulatedwithaspecificAndroidplatformorGoogleaddonInstead,youusetheSDKManagertoinstallorupdateSDKcomponentssuchasplatforms,tools,addons,anddocumentationInordertostartdevelopingapplications,youmustinstallatleastoneversionoftheAndroidplatformusingtheSDKManagerThisrequiresanInternetconnection,soifyouplantousetheSDKoffline,pleasemakesuretodownloadthenecessarycomponentswhileonlineAtthispoint,itisrecommendedtoaddtheAndroidSDKtoolsdirectorytothedevelopmentenvironmentsystemPATHvariableThetoolsdirectorycanbefoundundertheprecedingunpackedrootdirectory:<sdk>toolsHavingthebinariesandtoolsonthepathwillmakeitalotmoreconvenienttoissueAndroidSDKcommandsfromanywhereontheterminalconsoleofyourdevelopmentsystemAsanexample,afteraddingtheappropriateentriestotheshelluserloginscriptformyGNULinuxdevelopmentsystem,wereceivethefollowingoutputfromlistingitwiththeLinuxcatcommand:$cat~bashrc#googleandroiddevtoolsexportPATH="$PATH:~androidsdklinuxtools"exportPATH="$PATH:~androidsdklinuxplatformtools"AndroidSDKrelease,AndroidplatformCHAPTER:AndroidFundamentalsSETTINGTHEPATHONWINDOWS:Fromthedesktop,rightclickMyComputerandclickPropertiesAlternatively,fromControlPanel,doubleclickSystemBothoptionsopentheSystemPropertiesdialogboxNowclicktheAdvancedtabIntheAdvancedsection,clicktheEnvironmentVariablesbuttonIntheEnvironmentVariableswindow,selectthePATHvariableintheUserorSystemVariablesection,dependingonwhetheryouwantthesettingappliedforallusersorjustyourselfClicktheEditbuttonAddormodifythepathDirectoriesareseparatedbyasemicolonClickOKwhendoneForconfirmation,issuingthefollowingcommandonyourdevelopmentsystemwillprintthecurrentvalueofthesystemPATHvariabletotheterminalconsolewindowLinuxandMacOSX:echo$PATHWindows:echoPATHAndroidPlatformAPILevelsTheAPIleveltargetedbyyourapplicationisveryimportantforreasonsofdevicecompatibilityandthesoftwaredevelopmentandmaintenancelifetimeofyourcodebaseIfitisnotmanagedproperly,themaintenanceofyourapplicationcouldpotentiallybecomeanightmare,especiallyifitisdeployedtomultipleAndroiddevicesandoperatingplatformsItisalsoagoodideatobecomefamiliarwiththefolderstructuresoftheAndroidSDKonceitisinstalledAgain,thisisespeciallyvalidifyourapplicationswillbebuiltformultipleAndroidhardwaretargetsForabetterunderstandingofthesubjectofAPIlevels,itiswellworththeeffortofreviewingthedocumentationfoundontheofficialdeveloper’swebsiteforAndroidAPIlevelsThetieinbetweenAPIlevelnumbersandtheircorrespondingplatformsareclarifiedinTable–,whichwascurrentatthetimeofwritinghttp:developerandroidcomguideappendixapilevelshtmlCHAPTER:AndroidFundamentalsTable–AndroidPlatformVersionsandAPILevelsPlatformVersionAPILevelAndroidAndroidAndroidAndroidAndroidAndroidAndroidAndroidAndroidAndroidPlatformSetupHereisashortlistofdependenciesforproceedingwiththesetupofSDKplatforms:AndroidSDKstarterpackagedownloadedandunpackedTheJDK,ADK,andAnttoolsareaccessibleontheenvironmentpathWehaveabasicunderstandingofAndroidplatformversionsandAPIlevelsLastbutnotleast,weshouldbeconnectedtotheInternetWecannowinstalltheSDKplatformcomponentsusingtheAndroidSDKandAVDManagerprogramsTostarttheSDKManageronLinuxorMacOSX,executethefollowingcommand:$androidTostarttheSDKManageronWindows,runthefollowingprogram:SDKManagerexeThemainuserinterfaceoftheAndroidSDKManageronLinuxshouldappearasinFigure–CHAPTER:AndroidFundamentalsFigure–TheAndroidSDKandAVDManagerduringinitialSDKsetuponLinuxWINDOWSUSBDRIVERFORANDROIDDEVICES:ItisworthshowingtheequivalentAndroidSDKandAVDManagerfortheWindowsplatform(seeFigure–)Itcontainsanimportantaddition,theWindowsUSBDriverpackageforAndroiddevicesThiswillbecomenecessarywhenyoudevelop,debug,anddeploydirectlyinconjunctionwithaphysicalAndroidphoneorotherAndroidhardwaredeviceattachedviaUSBcabletoaWindowscomputerCHAPTER:AndroidFundamentalsFigure–TheAndroidSDKandAVDManagerduringinitialSDKsetuponWindowsNotethatinbothcaseswehaveselectedtheAndroidplatform,APIlevel,plustherelevantadditionssuchasdocumentationandSDKsamplesNowclickInstallSelectedTheappropriateSDKresourcebundleswillnowbedownloadedandinstalledintotheSDKdirectorystructurewhereweunpackedtheSDKstarterarchiveInordertomaintainandupdateyourSDKovertime,anupdatesessioncanbedirectlyinitiatedfromthecommandlinebyexecutingthefollowingcommands:InaterminalsessiononLinuxMacOSX:$androidupdatesdkBesidestheoptionofsimplyrunningSDKManagerexeagain,thesamecanbeachievedfromtheWindowscommandpromptwiththefollowing:C:>androidbatupdatesdkCHAPTER:AndroidFundamentalsAgain,weassumethattheAndroidtoolscanbefoundonthesystempathFurtherinformationaboutmanagingyourAndroidSDKinstallationcanbefoundontheAndroidDevelopers“AddingSDKComponents”pageExtraTools:ApacheAntTherearesomedevelopmenttoolsthatnoJavadevelopershoulddowithoutOnesuchanindispensableutilityisApacheAnt,whichisabuildtoolthatisJava'sroughequivalenttomakemakeistraditionallyusedinCCdevelopmentenvironmentsAntalsodiffersfrommakeinthatitusesXMLtospecifybuildstepsandactionsTheAndroidSDKextensivelyusesAntforitscompilation,build,anddeploymentinfrastructureWewilluseittotestdriveourcoretoolsinthenextsectionSoifitisnotalreadyinstalledonyoursystem,werecommendyougrabacopyandinstallitIfnecessary,youcanfindinstallationinstructionsandmoreinformationaboutAntontheofficialAntwebsiteSOMEIDESALREADYCONTAINANT:IfyouwillbeusinganIDEexclusively,installingastandaloneinstanceofApacheAntmightnotbenecessaryIDEssuchasEclipseandNetBeanscomepackagedwithanAntdistributionthattheyinvokebehindthescenesduringthebuildprocessIfyouareplanningtoworkthroughtheexamplesthatfollow,ensurethatAntisonthesystemenvironmentpathonceitisinstalledAndroidSDKTestDriveWewillnowtakeourSDKandplatforminstallationforacomprehensivetestdrivetocompletetheinstallationofruntimecomponentsandtoconfirmthateverythingwassetupcorrectlyWewillalsogettoknowtheenvironmentbetterThisisacentralpartofthischapterandwillformthebasisoffurthersubjectscoveredInitially,wewilldotheworkfromtheterminalconsole,commandline,orcommandprompt,whicheverterminologyisappropriateforyoursystemorpersonalpreferenceCreateanapplicationprojectdirectorytoworkinandcallitHelloAndroidSdkFromwithinaparentorhomedirectoryofyourchoicesomewhereonyoursystem,issuethefollowingcommands:OnLinuxorMacOSX:$mkdirHelloAndroidSdk$cdHelloAndroidSdkhttp:developerandroidcomsdkaddingcomponentshtmlhttp:antapacheorgDownloadfromWow!eBook<wwwwowebook

职业精品

用户评论

0/200
    暂无评论

精彩专题

上传我的资料

热门资料

资料评价:

/49
禁止下载

意见
反馈

返回
顶部

Q