完整版Android外文文献翻译.docx

上传人:b****2 文档编号:13998767 上传时间:2023-06-19 格式:DOCX 页数:21 大小:31.15KB
下载 相关 举报
完整版Android外文文献翻译.docx_第1页
第1页 / 共21页
完整版Android外文文献翻译.docx_第2页
第2页 / 共21页
完整版Android外文文献翻译.docx_第3页
第3页 / 共21页
完整版Android外文文献翻译.docx_第4页
第4页 / 共21页
完整版Android外文文献翻译.docx_第5页
第5页 / 共21页
完整版Android外文文献翻译.docx_第6页
第6页 / 共21页
完整版Android外文文献翻译.docx_第7页
第7页 / 共21页
完整版Android外文文献翻译.docx_第8页
第8页 / 共21页
完整版Android外文文献翻译.docx_第9页
第9页 / 共21页
完整版Android外文文献翻译.docx_第10页
第10页 / 共21页
完整版Android外文文献翻译.docx_第11页
第11页 / 共21页
完整版Android外文文献翻译.docx_第12页
第12页 / 共21页
完整版Android外文文献翻译.docx_第13页
第13页 / 共21页
完整版Android外文文献翻译.docx_第14页
第14页 / 共21页
完整版Android外文文献翻译.docx_第15页
第15页 / 共21页
完整版Android外文文献翻译.docx_第16页
第16页 / 共21页
完整版Android外文文献翻译.docx_第17页
第17页 / 共21页
完整版Android外文文献翻译.docx_第18页
第18页 / 共21页
完整版Android外文文献翻译.docx_第19页
第19页 / 共21页
完整版Android外文文献翻译.docx_第20页
第20页 / 共21页
亲,该文档总共21页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

完整版Android外文文献翻译.docx

《完整版Android外文文献翻译.docx》由会员分享,可在线阅读,更多相关《完整版Android外文文献翻译.docx(21页珍藏版)》请在冰点文库上搜索。

完整版Android外文文献翻译.docx

完整版Android外文文献翻译

AndroidApplicationFundamentals

AndroidapplicationsarewrittenintheJavaprogramminglanguage.TheAndroidSDKtoolscompilethecode—alongwithanydataandresourcefiles—intoan Androidpackage,anarchivefilewithan .apk suffix.Allthecodeinasingle .apk fileisconsideredtobeoneapplicationandisthefilethatAndroid-powereddevicesusetoinstalltheapplication.

Onceinstalledonadevice,eachAndroidapplicationlivesinitsownsecuritysandbox:

TheAndroidoperatingsystemisamulti-userLinuxsysteminwhicheachapplicationisadifferentuser.

Bydefault,thesystemassignseachapplicationauniqueLinuxuserID(theIDisusedonlybythesystemandisunknowntotheapplication).ThesystemsetspermissionsforallthefilesinanapplicationsothatonlytheuserIDassignedtothatapplicationcanaccessthem.

Eachprocesshasitsownvirtualmachine(VM),soanapplication'scoderunsinisolationfromotherapplications.

Bydefault,everyapplicationrunsinitsownLinuxprocess.Androidstartstheprocesswhenanyoftheapplication'scomponentsneedtobeexecuted,thenshutsdowntheprocesswhenit'snolongerneededorwhenthesystemmustrecovermemoryforotherapplications.

Inthisway,theAndroidsystemimplementsthe principleofleastprivilege.Thatis,eachapplication,bydefault,hasaccessonlytothecomponentsthatitrequirestodoitsworkandnomore.Thiscreatesaverysecureenvironmentinwhichanapplicationcannotaccesspartsofthesystemforwhichitisnotgivenpermission.

However,therearewaysforanapplicationtosharedatawithotherapplicationsandforanapplicationtoaccesssystemservices:

It'spossibletoarrangefortwoapplicationstosharethesameLinuxuserID,inwhichcasetheyareabletoaccesseachother'sfiles.Toconservesystemresources,applicationswiththesameuserIDcanalsoarrangetoruninthesameLinuxprocessandsharethesameVM(theapplicationsmustalsobesignedwiththesamecertificate).

Anapplicationcanrequestpermissiontoaccessdevicedatasuchastheuser'scontacts,SMSmessages,themountablestorage(SDcard),camera,Bluetooth,andmore.Allapplicationpermissionsmustbegrantedbytheuseratinstalltime.

ThatcoversthebasicsregardinghowanAndroidapplicationexistswithinthesystem.Therestofthisdocumentintroducesyouto:

1、Thecoreframeworkcomponentsthatdefineyourapplication.

2、Themanifestfileinwhichyoudeclarecomponentsandrequireddevicefeaturesforyourapplication.

3、Resourcesthatareseparatefromtheapplicationcodeandallowyourapplicationtogracefullyoptimizeitsbehaviorforavarietyofdeviceconfigurations.

ApplicationComponents

ApplicationcomponentsaretheessentialbuildingblocksofanAndroidapplication.Eachcomponentisadifferentpointthroughwhichthesystemcanenteryourapplication.Notallcomponentsareactualentrypointsfortheuserandsomedependoneachother,buteachoneexistsasitsownentityandplaysaspecificrole—eachoneisauniquebuildingblockthathelpsdefineyourapplication'soverallbehavior.

Therearefourdifferenttypesofapplicationcomponents.Eachtypeservesadistinctpurposeandhasadistinctlifecyclethatdefineshowthecomponentiscreatedanddestroyed.

Herearethefourtypesofapplicationcomponents:

Activities

An activity representsasinglescreenwithauserinterface.Forexample,anemailapplicationmighthaveoneactivitythatshowsalistofnewemails,anotheractivitytocomposeanemail,andanotheractivityforreadingemails.Althoughtheactivitiesworktogethertoformacohesiveuserexperienceintheemailapplication,eachoneisindependentoftheothers.Assuch,adifferentapplicationcanstartanyoneoftheseactivities(iftheemailapplicationallowsit).Forexample,acameraapplicationcanstarttheactivityintheemailapplicationthatcomposesnewmail,inorderfortheusertoshareapicture.

Anactivityisimplementedasasubclassof Activity andyoucanlearnmoreaboutitinthe Activities developerguide.

Services

A service isacomponentthatrunsinthebackgroundtoperformlong-runningoperationsortoperformworkforremoteprocesses.Aservicedoesnotprovideauserinterface.Forexample,aservicemightplaymusicinthebackgroundwhiletheuserisinadifferentapplication,oritmightfetchdataoverthenetworkwithoutblockinguserinteractionwithanactivity.Anothercomponent,suchasanactivity,canstarttheserviceandletitrunorbindtoitinordertointeractwithit.

Aserviceisimplementedasasubclassof Service andyoucanlearnmoreaboutitinthe Services developerguide.

Contentproviders

A contentprovider managesasharedsetofapplicationdata.Youcanstorethedatainthefilesystem,anSQLitedatabase,ontheweb,oranyotherpersistentstoragelocationyourapplicationcanaccess.Throughthecontentprovider,otherapplicationscanqueryorevenmodifythedata(ifthecontentproviderallowsit).Forexample,theAndroidsystemprovidesacontentproviderthatmanagestheuser'scontactinformation.Assuch,anyapplicationwiththeproperpermissionscanquerypartofthecontentprovider(suchas ContactsContract.Data)toreadandwriteinformationaboutaparticularperson.

Contentprovidersarealsousefulforreadingandwritingdatathatisprivatetoyourapplicationandnotshared.Forexample,the NotePad sampleapplicationusesacontentprovidertosavenotes.

Acontentproviderisimplementedasasubclassof ContentProvider andmustimplementastandardsetofAPIsthatenableotherapplicationstoperformtransactions.Formoreinformation,seethe ContentProviders developerguide.

Broadcastreceivers

A broadcastreceiver isacomponentthatrespondstosystem-widebroadcastannouncements.Manybroadcastsoriginatefromthesystem—forexample,abroadcastannouncingthatthescreenhasturnedoff,thebatteryislow,orapicturewascaptured.Applicationscanalsoinitiatebroadcasts—forexample,toletotherapplicationsknowthatsomedatahasbeendownloadedtothedeviceandisavailableforthemtouse.Althoughbroadcastreceiversdon'tdisplayauserinterface,theymay createastatusbarnotification toalerttheuserwhenabroadcasteventoccurs.Morecommonly,though,abroadcastreceiverisjusta"gateway"toothercomponentsandisintendedtodoaveryminimalamountofwork.Forinstance,itmightinitiateaservicetoperformsomeworkbasedontheevent.

Abroadcastreceiverisimplementedasasubclassof BroadcastReceiver andeachbroadcastisdeliveredasan Intent object.Formoreinformation,seetheBroadcastReceiver class.

AuniqueaspectoftheAndroidsystemdesignisthatanyapplicationcanstartanotherapplication’scomponent.Forexample,ifyouwanttheusertocaptureaphotowiththedevicecamera,there'sprobablyanotherapplicationthatdoesthatandyourapplicationcanuseit,insteadofdevelopinganactivitytocaptureaphotoyourself.Youdon'tneedtoincorporateorevenlinktothecodefromthecameraapplication.Instead,youcansimplystarttheactivityinthecameraapplicationthatcapturesaphoto.Whencomplete,thephotoisevenreturnedtoyourapplicationsoyoucanuseit.Totheuser,itseemsasifthecameraisactuallyapartofyourapplication.

Whenthesystemstartsacomponent,itstartstheprocessforthatapplication(ifit'snotalreadyrunning)andinstantiatestheclassesneededforthecomponent.Forexample,ifyourapplicationstartstheactivityinthecameraapplicationthatcapturesaphoto,thatactivityrunsintheprocessthatbelongstothecameraapplication,notinyourapplication'sprocess.Therefore,unlikeapplicationsonmostothersystems,Androidapplicationsdon'thaveasingleentrypoint(there'sno main() function,forexample).

Becausethesystemrunseachapplicationinaseparateprocesswithfilepermissionsthatrestrictaccesstootherapplications,yourapplicationcannotdirectlyactivateacomponentfromanotherapplication.TheAndroidsystem,however,can.So,toactivateacomponentinanotherapplication,youmustdeliveramessagetothesystemthatspecifiesyour intent tostartaparticularcomponent.Thesystemthenactivatesthecomponentforyou.

ActivatingComponents

Threeofthefourcomponenttypes—activities,services,andbroadcastreceivers—areactivatedbyanasynchronousmessagecalledan intent.Intentsbindindividualcomponentstoeachotheratruntime(youcanthinkofthemasthemessengersthatrequestanactionfromothercomponents),whetherthecomponentbelongstoyourapplicationoranother.

Anintentiscreatedwithan Intent object,whichdefinesamessagetoactivateeitheraspecificcomponentoraspecific type ofcomponent—anintentcanbeeitherexplicitorimplicit,respectively.

Foractivitiesandservices,anintentdefinestheactiontoperform(forexample,to"view"or"send"something)andmayspecifytheURIofthedatatoacton(amongotherthingsthatthecomponentbeingstartedmightneedtoknow).Forexample,anintentmightconveyarequestforanactivitytoshowanimageortoopenawebpage.Insomecases,youcanstartanactivitytoreceivearesult,inwhichcase,theactivityalsoreturnstheresultinan Intent (forexample,youcanissueanintenttolettheuserpickapersonalcontactandhaveitreturnedtoyou—thereturnintentincludesaURIpointingtothechosencontact).

Forbroadcastreceivers,theintentsimplydefinestheannouncementbeingbroadcast(forexample,abroadcasttoindicatethedevicebatteryislowincludesonlyaknownactionstringthatindicates"batteryislow").

Theothercomponenttype,contentpro

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

当前位置:首页 > 经管营销 > 金融投资

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2