外文文献Android Application Fundamentals安卓应用基础.docx

上传人:b****4 文档编号:4317271 上传时间:2023-05-07 格式:DOCX 页数:25 大小:30.08KB
下载 相关 举报
外文文献Android Application Fundamentals安卓应用基础.docx_第1页
第1页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第2页
第2页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第3页
第3页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第4页
第4页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第5页
第5页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第6页
第6页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第7页
第7页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第8页
第8页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第9页
第9页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第10页
第10页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第11页
第11页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第12页
第12页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第13页
第13页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第14页
第14页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第15页
第15页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第16页
第16页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第17页
第17页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第18页
第18页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第19页
第19页 / 共25页
外文文献Android Application Fundamentals安卓应用基础.docx_第20页
第20页 / 共25页
亲,该文档总共25页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

外文文献Android Application Fundamentals安卓应用基础.docx

《外文文献Android Application Fundamentals安卓应用基础.docx》由会员分享,可在线阅读,更多相关《外文文献Android Application Fundamentals安卓应用基础.docx(25页珍藏版)》请在冰点文库上搜索。

外文文献Android Application Fundamentals安卓应用基础.docx

外文文献AndroidApplicationFundamentals安卓应用基础

外文文献-AndroidApplicationFundamentals安卓应用基础

毕业设计

外文文献原文及译文

AndroidApplicationFundamentals

安卓应用基础

学生姓名:

学号:

计算机系系别:

网络工程专业:

指导教师:

2015年5月

中北大学信息商务学院2015届毕业设计外文文献原文及译文

AndroidApplicationFundamentals

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,

中北大学信息商务学院2015届毕业设计外文文献原文及译文

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

中北大学信息商务学院2015届毕业设计外文文献原文及译文

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

中北大学信息商务学院2015届毕业设计外文文献原文及译文

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.

中北大学信息商务学院2015届毕业设计外文文献原文及译文

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

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

当前位置:首页 > 工程科技 > 信息与通信

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

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