该【文献翻译-安卓应用基础 】是由【Q+1243595614】上传分享,文档一共【23】页,该文档可以免费在线阅读,需要了解更多关于【文献翻译-安卓应用基础 】的内容,可以使用淘豆网的站内搜索功能,选择自己适合的文档,以下文字是截取该文章内的部分文字,如需要获得完整电子版,请下载此文档到您的设备,方便您编辑和打印。武汉理工大学毕业设计(论文)
2
英文及翻译
英文原文
AndroidApplicationFundamentals
—alongwithanydataandresourcefiles—intoan Androidpackage,anarchivefilewithan .apk -powereddevicesusetoinstalltheapplication.
Onceinstalledonadevice,eachAndroidapplicationlivesinitsownsecuritysandbox:
●TheAndroidoperatingsystemisamulti-userLinuxsysteminwhicheachapplicationisadifferentuser.
●Bydefault,thesystemassignseachapplicationauniqueLinuxuserID(theIDisusedonlybythesystemandisunknowntotheapplication).ThesystemsetspermissionsforallthefilesinanapplicationsothatonlytheuserIDassignedtothatapplicationcanaccessthem.
●Eachprocesshasitsownvirtualmachine(VM),soanapplication'scoderunsinisolationfromotherapplications.
●Bydefault,'scomponentsneedtobeexecuted,thenshutsdowntheprocesswhenit'snolongerneededorwhenthesystemmustrecovermemoryforotherapplications.
Inthisway,theAndroidsystemimplementsthe ,eachapplication,bydefault,.
武汉理工大学毕业设计(论文)
2
However,therearewaysforanapplicationtosharedatawithotherapplicationsandforanapplicationtoaccesssystemservices:
It'spossibletoarrangefortwoapplicationstosharethesameLinuxuserID,inwhichcasetheyareabletoaccesseachother',applicationswiththesameuserIDcanalsoarrangetoruninthesameLinuxprocessandsharethesameVM(theapplicationsmustalsobesignedwiththesamecertificate).
Anapplicationcanrequestpermissiontoaccessdevicedatasuchastheuser'scontacts,SMSmessages,themountablestorage(SDcard),camera,Bluetooth,.
:
●Thecoreframeworkcomponentsthatdefineyourapplication.
●Themanifestfileinwhichyoudeclarecomponentsandrequireddevicefeaturesforyourapplication.
●Resourcesthatareseparatefromtheapplicationcodeandallowyourapplicationtogracefullyoptimizeitsbehaviorforavarietyofdeviceconfigurations.
ApplicationComponents
,buteachoneexistsasitsownentityandplaysaspecificrole—eachoneisauniquebuildingblockthathelpsdefineyourapplication'soverallbehavior.
武汉理工大学毕业设计(论文)
4
.
Herearethefourtypesofapplicationcomponents:
Activities
An activity ,anemailapplicationmighthaveoneactivitythatshowsalistofnewemails,anotheractivitytocomposeanemail,,,adifferentapplicationcanstartanyoneoftheseactivities(iftheemailapplicationallowsit).Forexample,acameraapplicationcanstarttheactivityintheemailapplicationthatcomposesnewmail,inorderfortheusertoshareapicture.
Anactivityisimplementedasasubclassof Activity andyoucanlearnmoreaboutitinthe Activities developerguide.
Services
A service isacomponentthatrunsinthebackgroundtoperformlong-,aservicemightplaymusicinthebackgroundwhiletheuserisinadifferentapplication,,suchasanactivity,canstarttheserviceandletitrunorbindtoitinordertointeractwithit.
Aserviceisimplementedasasubclassof Service andyoucanlearnmoreaboutitinthe Services developerguide.
Contentproviders
A contentprovider ,anSQLitedatabase,ontheweb,,otherapplicationscanqueryorevenmodifythedata(ifthecontentproviderallowsit).Forexample,theAndroidsystemprovidesacontentproviderthatmanagestheuser',anyapplicationwiththeproperpermissionscanquerypartofthecontentprovider(suchas
武汉理工大学毕业设计(论文)
4
)toreadandwriteinformationaboutaparticularperson.
,the NotePad sampleapplicationusesacontentprovidertosavenotes.
Acontentproviderisimplementedasasubclassof ContentProvider ,seethe ContentProviders developerguide.
Broadcastreceivers
A broadcastreceiver isacomponentthatrespondstosystem-—forexample,abroadcastannouncingthatthescreenhasturnedoff,thebatteryislow,—forexample,'tdisplayauserinterface,theymay createastatusbarnotification ,though,abroadcastreceiverisjusta"gateway",itmightinitiateaservicetoperformsomeworkbasedontheevent.
Abroadcastreceiverisimplementedasasubclassof BroadcastReceiver andeachbroadcastisdeliveredasan Intent ,seetheBroadcastReceiver class.
AuniqueaspectoftheAndroidsystemdesignisthatanyapplicationcanstartanotherapplication’,ifyouwanttheusertocaptureaphotowiththedevicecamera,there'sprobablyanotherapplicationthatdoesthatandyourapplicationcanuseit,',,,itseemsasifthecameraisactuallyapartofyourapplication.
武汉理工大学毕业设计(论文)
5
Whenthesystemstartsacomponent,itstartstheprocessforthatapplication(ifit'snotalreadyrunning),ifyourapplicationstartstheactivityinthecameraapplicationthatcapturesaphoto,thatactivityrunsintheprocessthatbelongstothecameraapplication,notinyourapplication',unlikeapplicationsonmostothersystems,Androidapplicationsdon'thaveasingleentrypoint(there'sno main() function,forexample).
Becausethesystemrunseachapplicationinaseparateprocesswithfilepermissionsthatrestrictaccesstootherapplications,,however,,toactivateacomponentinanotherapplication,youmustdeliveramessagetothesystemthatspecifiesyour intent .
ActivatingComponents
Threeofthefourcomponenttypes—activities,services,andbroadcastreceivers—areactivatedbyanasynchronousmessagecalledan (youcanthinkofthemasthemessengersthatrequestanactionfromothercomponents),whetherthecomponentbelongstoyourapplicationoranother.
Anintentiscreatedwithan Intent object,whichdefinesamessagetoactivateeitheraspecificcomponentoraspecific type ofcomponent—anintentcanbeeitherexplicitorimplicit,respectively.
Foractivitiesandservices,anintentdefinestheactiontoperform(forexample,to"view"or"send"something)andmayspecifytheURIofthedatatoacton(amongotherthingsthatthecomponentbeingstartedmightneedtoknow).Forexample,,youcanstartanactivitytoreceivearesult,inwhichcase,theactivityalsoreturnstheresultinan
武汉理工大学毕业设计(论文)
6
Intent (forexample,youcanissueanintenttolettheuserpickapersonalcontactandhaveitreturnedtoyou—thereturnintentincludesaURIpointingtothechosencontact).
Forbroadcastreceivers,theintentsimplydefinestheannouncementbeingbroadcast(forexample,abroadcasttoindicatethedevicebatteryislowincludesonlyaknownactionstringthatindicates"batteryislow").
Theothercomponenttype,contentprovider,,itisactivatedwhentargetedbyarequestfroma 'sperformingtransactionswiththeproviderdoesn'tneedtoandinsteadcallsmethodsonthe ContentResolver (forsecurity).
Thereareseparatemethodsforactivatingeachtypeofcomponent:
●Youcanstartanactivity(orgiveitsomethingnewtodo)bypassingan Intent to startActivity() or startActivityForResult() (whenyouwanttheactivitytoreturnaresult).
●Youcanstartaservice(orgivenewinstructionstoanongoingservice)bypassingan Intent to startService().Oryoucanbindtotheservicebypassingan Intent tobindService().
●Youcaninitiateabroadcastbypassingan Intent tomethodslike sendBroadcast(), sendOrderedBroadcast(),or sendStickyBroadcast().
●Youcanperformaquerytoacontentproviderbycalling query() ona ContentResolver.
Formoreinformationaboutusingintents,seethe IntentsandIntentFilters :Activities, Services, BroadcastReceiverandContentProviders.
武汉理工大学毕业设计(论文)
7
Declaringcomponents
Theprimarytaskofthemanifestistoinformthesystemabouttheapplication',amanifestfilecandeclareanactivityasfollows:
<?xmlversion=""encoding="utf-8"?>
<manifest...>
<applicationandroid:icon="***@drawable/"...>
<activityandroid:name=""
android:label="***@string/example_label"...>
</activity>
...
</application>
</manifest>
Inthe <application> element,the android:icon attributepointstoresourcesforaniconthatidentifiestheapplication.
Inthe <activity> element,the android:name attributespecifiesthefullyqualifiedclassnameofthe Activity subclassandthe android:label attributesspecifiesastringtouseastheuser-visiblelabelfortheactivity.
Youmustdeclareallapplicationcomponentsthisway:
●<activity> elementsforactivities
●<service> elementsforservices
●<receiver> elementsforbroadcastreceivers
●<provider> elementsforcontentproviders
Activities,services,andcontentprovidersthatyouincludeinyoursourcebutdonotdeclareinthemanifestarenotvisibletothesystemand,consequently,,broadcastreceiverscanbeeitherdeclaredinthemanifestorcreateddynamicallyincode(as BroadcastReceiver objects)andregisteredwiththesystembycalling registerReceiver().
武汉理工大学毕业设计(论文)
9
Declaringcomponentcapabilities
Asdiscussedabove,in ActivatingComponents,youcanusean Intent tostartactivities,services,(usingthecomponentclassname),,yousimplydescribethetypeofactionyouwanttoperform(andoptionally,thedatauponwhichyou’dliketoperformtheaction),thentheuserselectswhichonetouse.
Thewaythesystemidentifiesthecomponentsthatcanrespondtoanintentisbycomparingtheintentreceivedtothe intentfilters providedinthemanifestfileofotherapplicationsonthedevice.
Whenyoudeclareacomponentinyourapplication'smanifest,youcanoptionallyincludeintentfiltersthatdeclarethecapabilitiesofthecomponentsoitcanrespondtointents
文献翻译-安卓应用基础 来自淘豆网m.daumloan.com转载请标明出处.