高级语言程序与开发(ME3323518)Android应用程序开发主讲:段江涛课程目标与考核方式目标:了解智能手机开发现状,Android平台体系结构和应用程序模型,结合Twitter应用案例,围绕以下技术应用,逐步细化Twitter应用程序,掌握Android应用开发的整个流程。平台综述开发环境程序结构数据存取网络连接硬件访问服务编程用户界面Twitter-likeapplication课程安排与考核方式课时:16学时,讲解Android平台体系结构、应用程序模型基本概念、循序渐进讲解8个Twitter应用案例设计思想。上机:28学时,8个Twitter应用案例上机练习。考核:以小组为单位(5人以内),大作业,以考查方式评定成绩。教材LearningAndroid•Object-orientedprogrammers•BuildaTwitter-likeapplication,addingnewfeatureswitheachchapter.•OverviewoftheAndroidplatform•Androidapplicationframework,andthestructureanddistributionofapplicationpackages(APK)•Androiddevelopmentenvironment•UseAndroid’sbuildingblocks—Activities,Intents,Services,ContentProviders,andBroadcastReceivers•LearnhowtobuildbasicAndroiduserinterfacesandorganizeUIelementsinViewsandLayoutsWhat’sInside•Chapter1,AndroidOverview–IntroductiontoAndroidanditshistory•Chapter2,TheStack–OverviewoftheAndroidoperatingsystemandallitspartsfromaveryhighlevel•Chapter3,QuickStart–SetupyourenvironmentforAndroidapplicationdevelopment•Chapter4,MainBuildingBlocks–ExplainstheAndroidcomponentsapplicationdevelopersusetoputtogetheranappWhat’sInside•Chapter5,YambaProjectOverview–ExplainstheYambaapplicationthatwe’llbuildtogetherthroughthisbookanduseasanexampletolearnAndroid’svariousfeatures•Chapter6,AndroidUserInterface–Explainshowtobuildtheuserinterfaceforyourapplication•Chapter7,Preferences,theFilesystem,theOptionsMenu,andIntents–Coverssomeoftheoperatingsystemfeaturesthatmakeanapplicationdeveloper’slifeeasier•Chapter8,Services–CoversbuildinganAndroidservicetoprocessbackgroundtasksWhat’sInside•Chapter9,TheDatabase–Explainsthebuilt-inSQLitedatabaseandhowtouseittopersistthedatainyourownapplication•Chapter10,ListsandAdapters–CoversanimportantfeatureofAndroidthatallowslargedatasetstobelinkedefficientlytorelativelysmallscreens•Chapter11,BroadcastReceivers–Explainshowtousethepublish-subscribemechanisminAndroidtorespondtovarioussystemanduser-definedmessages•Chapter12,ContentProviders–Showshowtodesignacontentprovidertosharedatabetweenapplications,inthiscaseusingittoenableourappwidgettodisplaydataonthehomescreenWhat’sInside•Chapter13,SystemServices–Introducesvarioussystemservicesthatanappdevelopercantapinto•Chapter14,TheAndroidInterfaceDefinitionLanguage–Coversbuildinganinter-processcommunicationmechanismtoallowforremoteaccesstoaservicefromanotherapplication•Chapter15,TheNativeDevelopmentKit(NDK)–IntroduceshowtowritenativeCcodeaspartofyourAndroidapplicationCHAPTER1AndroidOverview•Opensourceplatformdesignedformobiledevices.•ItischampionedbyGoogleandownedbyOpenHandsetAlliance.•Androidprovidesallthetoolsandframeworksfordevelopingmobileappsquicklyandeasily.History•In2005,GooglebuysAndroid,Inc.Theworldthinksa“gPhone”isabouttocomeout.•In2007,theOpenHandsetAllianceisannounced.Androidisofficiallyopensourced.•In2008,theAndroidSDK1.0isreleased.TheG1phone,manufacturedbyHTCandsoldbythewirelesscarrierT-MobileUSA,followsshortlyafterward.•2009,Newversionsoftheoperatingsystemarereleased:Cupcake(1.5),Donut(1.6),andEclair(2.0and2.1).Morethan20devicesrunAndroid.•In2010,Froyo(Android2.2)isreleasedandsoaremorethan60devicesthatrunit.•Android2.3,Revision1(December2010)•Android2.3.3,Revision1(February2011)•Android3.0,Revision1(February2011)AndroidVersionsAndroidversionAPIlevelNicknameAndroid1.01Android1.12Android1.53CupcakeAndroid1.64DonutAndroid2.05EclairAndroid2.016EclairAndroid2.17EclairAndroid2.28Froyo(frozenyogurt)Android2.39GingerbreadAndroid2.3.310GingerbreadAndroid3.011HoneycombCHAPTER2TheStackAndroidandJavaStandardJavacollection•JavaStandardEdition(akaJ2SE)Usedfordevelopmentonbasicdesktop-typeapplications•JavaEnterpriseEdition(akaJ2EEorJavaEE)Usedfordevelopmentofenterpriseapplications•JavaMicroEdition(akaJ2MEorJavaME)JavaformobileapplicationsAndroidJava•Android’sJavasetoflibrariesisclosesttoJavaStandardEdition(J2SE).•Javauserinterfacelibraries(AWTandSwing)havebeentakenoutandreplacedwithAndroid-specificuserinterfacelibraries.•AndroidalsoaddsquiteafewnewfeaturestostandardJavawhilesupportingmostofJava’sstandardfeatures.•So,youhavemostofyourfavoriteJavalibrariesatyourdisposal,plusmanynewones.Applications•TheycancomepreinstalledonthedeviceorcanbedownloadedfromoneofthemanyAndroidmarkets.•Anapplicationisasingleapplicationpackage(APK)file.–Dalvikexecutable,Resources,Nativelibraries•ApplicationSigningCHAPTER3QuickStart•InstallingtheJDK6.0•InstallingtheEclipseIDE3.5(Galileo)•InstallingtheAndroidSDK–TheAndroidSoftwareDevelopmentKit(SDK)isallyouneedtodevelopapplicationsforAndroid.•InstallingtheAndroidDevelopmentToolsplugin(ADT)Hello,WorldCreatingaNewProjectHello,WorldProjectStructure•AndroidManifest.xml,whichisanXMLfiledescribingtheapplicationbeingbuiltandwhatcomponents–activities,services,etc.–arebeingsuppliedbythatapplication.•build.xml,whichisanAntscriptforcompilingtheapplicationandinstallingitonthedevice.•default.propertiesandlocal.properties,propertyfilesusedbytheAntbuildscript•assets/,whichholdotherstaticfilesyouwishpackagedwiththeapplicationfordeploymentontothedevice.thisisagoodlocation