外文文献Android Application Fundamentals安卓应用基础Word文档格式.docx
- 文档编号:6606098
- 上传时间:2023-05-07
- 格式:DOCX
- 页数:25
- 大小:30.08KB
外文文献Android Application Fundamentals安卓应用基础Word文档格式.docx
《外文文献Android Application Fundamentals安卓应用基础Word文档格式.docx》由会员分享,可在线阅读,更多相关《外文文献Android Application Fundamentals安卓应用基础Word文档格式.docx(25页珍藏版)》请在冰点文库上搜索。
网络工程专业:
指导教师:
2015年5月
中北大学信息商务学院2015届毕业设计外文文献原文及译文
AndroidapplicationsarewrittenintheJavaprogramminglanguage.TheAndroidSDKtoolscompilethecode—alongwithanydataandresourcefiles—intoanAndroidpackage,
anarchivefilewithan.apksuffix.Allthecodeinasingle.apkfileisconsideredtobeoneapplicationandisthefilethatAndroid-powereddevicesusetoinstalltheapplication.
Onceinstalledonadevice,eachAndroidapplicationlivesinitsownsecuritysandbox:
TheAndroidoperatingsystemisamulti-userLinuxsysteminwhicheach
applicationisadifferentuser.
Bydefault,thesystemassignseachapplicationauniqueLinuxuserID(theIDis
usedonlybythesystemandisunknowntotheapplication).Thesystemsets
permissionsforallthefilesinanapplicationsothatonlytheuserIDassignedto
thatapplicationcanaccessthem.
Eachprocesshasitsownvirtualmachine(VM),soanapplication'
scoderunsin
isolationfromotherapplications.
Bydefault,everyapplicationrunsinitsownLinuxprocess.Androidstartsthe
processwhenanyoftheapplication'
scomponentsneedtobeexecuted,thenshuts
downtheprocesswhenit'
snolongerneededorwhenthesystemmustrecover
memoryforotherapplications.
Inthisway,theAndroidsystemimplementstheprincipleofleastprivilege.Thatis,
eachapplication,bydefault,hasaccessonlytothecomponentsthatitrequirestodoitsworkandnomore.Thiscreatesaverysecureenvironmentinwhichanapplicationcannotaccesspartsofthesystemforwhichitisnotgivenpermission.
However,therearewaysforanapplicationtosharedatawithotherapplicationsandforanapplicationtoaccesssystemservices:
It'
spossibletoarrangefortwoapplicationstosharethesameLinuxuserID,in
whichcasetheyareabletoaccesseachother'
sfiles.Toconservesystemresources,
applicationswiththesameuserIDcanalsoarrangetoruninthesameLinux
processandsharethesameVM(theapplicationsmustalsobesignedwiththe
samecertificate).
Anapplicationcanrequestpermissiontoaccessdevicedatasuchastheuser'
s
contacts,SMSmessages,themountablestorage(SDcard),camera,Bluetooth,and
more.Allapplicationpermissionsmustbegrantedbytheuseratinstalltime.ThatcoversthebasicsregardinghowanAndroidapplicationexistswithinthesystem.Therestofthisdocumentintroducesyouto:
Thecoreframeworkcomponentsthatdefineyourapplication.
Themanifestfileinwhichyoudeclarecomponentsandrequireddevicefeatures
foryourapplication.
Resourcesthatareseparatefromtheapplicationcodeandallowyourapplication
togracefullyoptimizeitsbehaviorforavarietyofdeviceconfigurations.
ApplicationComponents
ApplicationcomponentsaretheessentialbuildingblocksofanAndroidapplication.Eachcomponentisadifferentpointthroughwhichthesystemcanenteryourapplication.Notallcomponentsareactualentrypointsfortheuserandsomedependoneachother,buteachoneexistsasitsownentityandplaysaspecificrole—eachoneisauniquebuilding
blockthathelpsdefineyourapplication'
soverallbehavior.
Therearefourdifferenttypesofapplicationcomponents.Eachtypeservesadistinctpurposeandhasadistinctlifecyclethatdefineshowthecomponentiscreatedanddestroyed.
Herearethefourtypesofapplicationcomponents:
Activities
Anactivityrepresentsasinglescreenwithauserinterface.Forexample,anemail
applicationmighthaveoneactivitythatshowsalistofnewemails,anotheractivity
tocomposeanemail,andanotheractivityforreadingemails.Althoughtheactivitiesworktogethertoformacohesiveuserexperienceintheemailapplication,eachoneisindependentoftheothers.Assuch,adifferentapplicationcanstartanyoneoftheseactivities(iftheemailapplicationallowsit).Forexample,acameraapplicationcanstarttheactivityintheemailapplicationthatcomposesnewmail,inorderfortheusertoshareapicture.
AnactivityisimplementedasasubclassofActivityandyoucanlearnmoreaboutitintheActivitiesdeveloperguide.
Services
Aserviceisacomponentthatrunsinthebackgroundtoperformlong-runningoperationsortoperformworkforremoteprocesses.Aservicedoesnotprovideauserinterface.Forexample,aservicemightplaymusicinthebackgroundwhiletheuserisinadifferentapplication,oritmightfetchdataoverthenetworkwithoutblockinguserinteractionwithanactivity.Anothercomponent,suchasanactivity,canstarttheserviceandletitrunorbindtoitinordertointeractwithit.AserviceisimplementedasasubclassofServiceandyoucanlearnmoreaboutitintheServicesdeveloperguide.
Contentproviders
Acontentprovidermanagesasharedsetofapplicationdata.Youcanstorethedatainthefilesystem,anSQLitedatabase,ontheweb,oranyotherpersistentstoragelocationyourapplicationcanaccess.Throughthecontentprovider,otherapplicationscanqueryorevenmodifythedata(ifthecontentproviderallowsit).Forexample,theAndroidsystemprovidesacontentproviderthatmanagestheuser'
scontactinformation.Assuch,anyapplicationwiththeproperpermissionscanquerypartofthecontentprovider(suchasContactsContract.Data)toreadandwriteinformationaboutaparticularperson.
Contentprovidersarealsousefulforreadingandwritingdatathatisprivatetoyour
applicationandnotshared.Forexample,theNotePadsampleapplicationusesa
contentprovidertosavenotes.
AcontentproviderisimplementedasasubclassofContentProviderandmust
implementastandardsetofAPIsthatenableotherapplicationstoperform
transactions.Formoreinformation,seetheContentProvidersdeveloperguide.Broadcastreceivers
Abroadcastreceiverisacomponentthatrespondstosystem-widebroadcast
announcements.Manybroadcastsoriginatefromthesystem—forexample,a
broadcastannouncingthatthescreenhasturnedoff,thebatteryislow,orapicture
wascaptured.Applicationscanalsoinitiatebroadcasts—forexample,toletother
applicationsknowthatsomedatahasbeendownloadedtothedeviceandis
availableforthemtouse.Althoughbroadcastreceiversdon'
tdisplayauser
interface,theymaycreateastatusbarnotificationtoalerttheuserwhenabroadcast
eventoccurs.Morecommonly,though,abroadcastreceiverisjusta"
gateway"
to
othercomponentsandisintendedtodoaveryminimalamountofwork.For
instance,itmightinitiateaservicetoperformsomeworkbasedontheevent.
AbroadcastreceiverisimplementedasasubclassofBroadcastReceiverandeach
broadcastisdeliveredasanIntentobject.Formoreinformation,see
theBroadcastReceiverclass.
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'
snomain()function,forexample).
Becausethesystemrunseachapplicationinaseparateprocesswithfilepermissionsthatrestrictaccesstootherapplications,yourapplicationcannotdirectlyactivateacomponentfromanotherapplication.TheAndroidsystem,however,can.So,toactivateacomponentinanotherapplication,youmustdeliveramessagetothesystemthatspecifiesyourintenttostartaparticularcomponent.Thesystemthenactivatesthecomponentforyou.
ActivatingComponents
Threeofthefourcomponenttypes—activities,services,andbroadcastreceivers—are
activatedbyanasynchronousmessagecalledanintent.Intentsbindindividualcomponents
toeachotheratruntime(youcanthinkofthemasthemessengersthatrequestanactionfromothercomponents),whetherthecomponentbelongstoyourapplicationoranother.
AnintentiscreatedwithanIntentobject,whichdefinesamessagetoactivateeitheraspecificcomponentoraspecifictypeofcomponent—anintentcanbeeitherexplicitor
implicit,respectively.
Foractivitiesandservices,anintentdefinestheactiontoperform(forexample,to"
view"
or"
send"
something)andmayspecifytheURIofthedatatoacton(amongotherthingsthatthecomponentbeingstartedmightneedtoknow).Forexample,anintentmightconveyarequestforanactivitytoshowanimageortoopenawebpage.Insomecases,youcanstartanactivitytoreceivearesult,inwhichcase,theactivityalsoreturnsth
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 外文文献Android Application Fundamentals安卓应用基础 外文 文献 Android Fundamentals 应用 基础
链接地址:https://www.bingdoc.com/p-6606098.html