android系统外文翻译.docx

上传人:b****8 文档编号:23867065 上传时间:2023-05-21 格式:DOCX 页数:17 大小:109.35KB
下载 相关 举报
android系统外文翻译.docx_第1页
第1页 / 共17页
android系统外文翻译.docx_第2页
第2页 / 共17页
android系统外文翻译.docx_第3页
第3页 / 共17页
android系统外文翻译.docx_第4页
第4页 / 共17页
android系统外文翻译.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

android系统外文翻译.docx

《android系统外文翻译.docx》由会员分享,可在线阅读,更多相关《android系统外文翻译.docx(17页珍藏版)》请在冰豆网上搜索。

android系统外文翻译.docx

android系统外文翻译

附录一:

英文翻译原文

Abstract

Withthedevelopmentofthemobilephonemarket,3Gmobilephonesystemdevelopmenthasalsobecomepopularonthemaket.ThispaperintroducessomebasicapplicationsoftheAndroidsystemaboutapartoftheApplicationFundamentasbooktranslation,sothatmorelearnerscaneasilylearnaboutthedevelopmentandapplicationoftheAndroidsystem.TranslationaboutthispaperismypersonalunderstandingoftheApplicationFundaments,therearesomesimilaritiesanddifferenceswiththeoriginal,andifyouwouldliketoknowmoreaboutormoredetailedaboutbasicapplicationofAndroidsystem,pleasereadtheoriginalarticlereferencedthisarticle,thispaperonlyintroducesbasicapplicationoftheAndroidsystemaboutapplicatedcomponent,closecomponent,manifestfile,theIntentfilter.

Keyword:

applicationcomponents,closedcomponents,Intentfilter,manifestfiles,activity,Service,Broadcastreceiver,Contentprovider

AndroidapplicationsarewrittenintheJavaprogramminglanguage.ThecompiledJavacode—alongwithanydataandresourcefilesrequiredbytheapplication—isbundledbytheaapttoolintoanAndroidpackage,anarchivefilemarkedbyan.apksuffix.Thisfileisthevehiclefordistributingtheapplicationandinstallingitonmobiledevices;it'sthefileusersdownloadtotheirdevices.Allthecodeinasingle.apkfileisconsideredtobeoneapplication.

Inmanyways,eachAndroidapplicationlivesinitsownworld:

1.Bydefault,everyapplicationrunsinitsownLinuxprocess.Androidstartstheprocesswhenanyoftheapplication'scodeneedstobeexecuted,andshutsdowntheprocesswhenit'snolongerneededandsystemresourcesarerequiredbyotherapplications.

2.Eachprocesshasitsownvirtualmachine(VM),soapplicationcoderunsinisolationfromthecodeofallotherapplications.

3.Bydefault,eachapplicationisassignedauniqueLinuxuserID.Permissionsaresetsothattheapplication'sfilesarevisibleonlytothatuserandonlytotheapplicationitself—althoughtherearewaystoexportthemtootherapplicationsaswell.

It'spossibletoarrangefortwoapplicationstosharethesameuserID,inwhichcasetheywillbeabletoseeeachother'sfiles.Toconservesystemresources,applicationswiththesameIDcanalsoarrangetoruninthesameLinuxprocess,sharingthesameVM.

ApplicationComponents

AcentralfeatureofAndroidisthatoneapplicationcanmakeuseofelementsofotherapplications(providedthoseapplicationspermitit).Forexample,ifyourapplicationneedstodisplayascrollinglistofimagesandanotherapplicationhasdevelopedasuitablescrollerandmadeitavailabletoothers,youcancalluponthatscrollertodothework,ratherthandevelopyourown.Yourapplicationdoesn'tincorporatethecodeoftheotherapplicationorlinktoit.Rather,itsimplystartsupthatpieceoftheotherapplicationwhentheneedarises.

Forthistowork,thesystemmustbeabletostartanapplicationprocesswhenanypartofitisneeded,andinstantiatetheJavaobjectsforthatpart.Therefore,unlikeapplicationsonmostothersystems,Androidapplicationsdon'thaveasingleentrypointforeverythingintheapplication(nomain()function,forexample).Rather,theyhaveessentialcomponentsthatthesystemcaninstantiateandrunasneeded.Therearefourtypesofcomponents:

Activities

Anactivitypresentsavisualuserinterfaceforonefocusedendeavortheusercanundertake.For

example,anactivitymightpresentalistofmenuitemsuserscanchoosefromoritmightdisplay

Photographsalongwiththeircaptions.Atextmessagingapplicationmighthaveoneactivitythatshowsalistofcontactstosendmessagesto,asecondactivitytowritethemessagetothechosencontact,andotheractivitiestoreviewoldmessagesorchangesettings.Thoughtheyworktogethertoformacohesiveuserinterface,eachactivityisindependentoftheothers.EachoneisimplementedasasubclassoftheActivitybaseclass.

Anapplicationmightconsistofjustoneactivityor,likethetextmessagingapplicationjustmentioned,itmaycontainseveral.Whattheactivitiesare,andhowmanytherearedepends,ofcourse,ontheapplicationanditsdesign.Typically,oneoftheactivitiesismarkedasthefirstonethatshouldbepresentedtotheuserwhentheapplicationislaunched.Movingfromoneactivitytoanotherisaccomplishedbyhavingthecurrentactivitystartthenextone.

Eachactivityisgivenadefaultwindowtodrawin.Typically,thewindowfillsthescreen,butitmightbesmallerthanthescreenandfloatontopofotherwindows.Anactivitycanalsomakeuseofadditionalwindows—forexample,apop-updialogthatcallsforauserresponseinthemidstoftheactivity,orawindowthatpresentsuserswithvitalinformationwhentheyselectaparticularitemon-screen.

Thevisualcontentofthewindowisprovidedbyahierarchyofviews—objectsderivedfromthebaseViewclass.Eachviewcontrolsaparticularrectangularspacewithinthewindow.Parentviewscontainandorganizethelayoutoftheirchildren.Leafviews(thoseatthebottomofthehierarchy)drawintherectanglestheycontrolandrespondtouseractionsdirectedatthatspace.Thus,viewsarewheretheactivity'sinteractionwiththeusertakesplace.

Forexample,aviewmightdisplayasmallimageandinitiateanactionwhentheusertapsthatimage.Androidhasanumberofready-madeviewsthatyoucanuse—includingbuttons,textfields,scrollbars,menuitems,checkboxes,andmore.

Aviewhierarchyisplacedwithinanactivity'swindowbytheActivity.setContentView()method.ThecontentviewistheViewobjectattherootofthehierarchy.(SeetheseparateUserInterfacedocumentformoreinformationonviewsandthehierarchy.)

Services

Aservicedoesn'thaveavisualuserinterface,butratherrunsinthebackgroundforanindefiniteperiodoftime.Forexample,aservicemightplaybackgroundmusicastheuserattendstoothermatters,oritmightfetchdataoverthenetworkorcalculatesomethingandprovidetheresulttoactivitiesthatneedit.EachserviceextendstheServicebaseclass.

Aprimeexampleisamediaplayerplayingsongsfromaplaylist.Theplayerapplicationwouldprobablyhaveoneormoreactivitiesthatallowtheusertochoosesongsandstartplayingthem.However,themusicplaybackitselfwouldnotbehandledbyanactivitybecauseuserswillexpectthemusictokeepplayingevenaftertheyleavetheplayerandbeginsomethingdifferent.Tokeepthemusicgoing,themediaplayeractivitycouldstartaservicetoruninthebackground.Thesystemwouldthenkeepthemusicplaybackservicerunningevenaftertheactivitythatstarteditleavesthescreen.

It'spossibletoconnectto(bindto)anongoingservice(andstarttheserviceifit'snotalreadyrunning).Whileconnected,youcancommunicatewiththeservicethroughaninterfacethattheserviceexposes.Forthemusicservice,thisinterfacemightallowuserstopause,rewind,stop,andrestarttheplayback.

Likeactivitiesandtheothercomponents,servicesruninthemainthreadoftheapplicationprocess.Sothattheywon'tblockothercomponentsortheuserinterface,theyoftenspawnanotherthreadfortime-consumingtasks(likemusicplayback).SeeProcessesandThreads,later.

Broadcastreceivers

Abroadcastreceiverisacomponentthatdoesnothingbutreceiveandreacttobroadcastannouncements.Manybroadcastsoriginateinsystemcode—forexample,announcementsthatthetimezonehaschanged,thatthebatteryislow,thatapicturehasbeentaken,orthattheuserchangedalanguagepreference.Applicationscanalsoinitiatebroadcasts—forexample,toletotherapplicationsknowthatsomedatahasbeendownloadedtothedeviceandisavailableforthemtouse.

Anapplicationcanhaveanynumberofbroadcastreceiverstorespondtoanyannouncementsitconsidersimportant.AllreceiversextendtheBroadcastReceiverbaseclass.

Broadcastreceiversdonotdisplayauserinterface.However,theymaystartanactivityinresponsetotheinformationtheyreceive,ortheymayusetheNotificationManagertoalerttheuser.Notificationscangettheuser'sattentioninvariousways—flashingthebacklight,vibratingthedevice,playingasound,andsoon.Theytypicallyplaceapersistenticoninthestatusbar,whichuserscanopentogetthemessage.

Contentproviders

Acontentprovidermakesaspecificsetoftheapplication'sdataavailabletootherapplications.Thedatacanbestoredinthefilesystem,inanSQLitedatabase,orinanyothermannerthatmakessense.ThecontentproviderextendstheContentProviderbaseclasstoimplementastandardsetofmethodsthatenableotherapplicationstoretrieveandstoredataofthetypeitcontrols.However,applicationsdonotcallthesemethodsdirectly.RathertheyuseaContentResolverobjectandcallitsmethodsinstead.AContentResolvercantalktoanycontentprovider;itcooperateswiththeprovidertomanageanyinterprocesscommunicationthat'sinvolved.

SeetheseparateContentProvidersdocumentformoreinformationonusingcontentproviders.

Wheneverthere'sarequestthatshouldbehandledbyaparticularcomponent,Androidmakessurethattheapplicationprocessofthecomponentisrunning,startingitifnecessary,andthatanappropriateinstanceofthecomponentisavailable,creatingtheinstanceifnecessary.

Activatingcomponents:

intents

Contentprovidersareactivatedwhenthey'retargetedbyarequestfromaContentResolver.Theotherthreecomponents—activities,services,andbroadcastreceivers—areactivatedbyasynchronousmessagescalledintents.AnintentisanIntentobjectthatholdsthecontento

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1