有关android技术英文文献翻译.docx

上传人:b****1 文档编号:14035865 上传时间:2023-06-20 格式:DOCX 页数:17 大小:27.70KB
下载 相关 举报
有关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_第6页
第6页 / 共17页
有关android技术英文文献翻译.docx_第7页
第7页 / 共17页
有关android技术英文文献翻译.docx_第8页
第8页 / 共17页
有关android技术英文文献翻译.docx_第9页
第9页 / 共17页
有关android技术英文文献翻译.docx_第10页
第10页 / 共17页
有关android技术英文文献翻译.docx_第11页
第11页 / 共17页
有关android技术英文文献翻译.docx_第12页
第12页 / 共17页
有关android技术英文文献翻译.docx_第13页
第13页 / 共17页
有关android技术英文文献翻译.docx_第14页
第14页 / 共17页
有关android技术英文文献翻译.docx_第15页
第15页 / 共17页
有关android技术英文文献翻译.docx_第16页
第16页 / 共17页
有关android技术英文文献翻译.docx_第17页
第17页 / 共17页
亲,该文档总共17页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

有关android技术英文文献翻译.docx

《有关android技术英文文献翻译.docx》由会员分享,可在线阅读,更多相关《有关android技术英文文献翻译.docx(17页珍藏版)》请在冰点文库上搜索。

有关android技术英文文献翻译.docx

有关android技术英文文献翻译

ApplicationFundamentals

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

Android应用基础:

Android应用程序是通过java语言开发的,通过绑定一些应用所需要的东西,例如:

编译的Java代码,加上数据和一些资源文件,使用一个apt的工具将所有的东西封装成一个android包,这个文件的文件后缀是.apk。

这个文件是分发并安装应用程序到移动设备的载体,是用户获得该应用程序所需要的下载的文件。

ApplicationComponentsAcentralfeatureofAndroidisthatoneapplicationcanmakeuseofelementsofotherapplications(providedthoseapplicationspermitit).Forexample,ifyourapplicationneedstodisplayascrollinglistofimagesandanotherapplicationhasdevelopedasuitablescrollerandmadeitavailabletoothers,youcancalluponthatscrollertodothework,ratherthandevelopyourown.Yourapplicationdoesn'tincorporatethecodeoftheotherapplicationorlinktoit.Rather,itsimplystartsupthatpieceoftheotherapplicationwhentheneedarises.Forthistowork,thesystemmustbeabletostartanapplicationprocesswhenanypartofitisneeded,andinstantiatetheJavaobjectsforthatpart.Therefore,unlikeapplicationsonmostothersystems,Androidapplicationsdon'thaveasingleentrypointforeverythingintheapplication(nomain()function,forexample).Rather,theyhaveessentialcomponentsthatthesystemcaninstantiateandrunasneeded.Therearefourtypesofcomponents:

ActivitiesAnactivitypresentsavisualuserinterfaceforonefocusedendeavortheusercanundertake.Forexample,anactivitymightpresentalistofmenuitemsuserscanchoosefromoritmightdisplayphotographsalongwiththeircaptions.Atextmessagingapplicationmighthaveoneactivitythatshowsalistofcontactstosendmessagesto,asecondactivitytowritethemessagetothechosencontact,andotheractivitiestoreviewoldmessagesorchangesettings.Thoughtheyworktogethertoformacohesiveuserinterface,eachactivityisindependentoftheothers.EachoneisimplementedasasubclassoftheActivitybaseclass.Anapplicationmightconsistofjustoneactivityor,likethetextmessagingapplicationjustmentioned,itmaycontainseveral.Whattheactivitiesare,andhowmanytherearedepends,ofcourse,ontheapplicationanditsdesign.Typically,oneoftheactivitiesismarkedasthefirstonethatshouldbepresentedtotheuserwhentheapplicationislaunched.Movingfromoneactivitytoanotherisaccomplishedbyhavingthecurrentactivitystartthenextone.

Android有四大应用程序组件

Android的一个很重要的中心特征就是一个应用程序能充分利用其他的应用程序的一些组件(前提是被允许的)例如:

如果的当前开发的应用需要一个滚动的列表去展示相片并且当时其他的程序已经开发了一个合适的滚动列表并且对其他人可用,你可以调用这个滚动的列表来完成你的工作而不是开发你自己的。

你的应用不需要包含那个应用的代码或来它。

相反,它只是简单的在你需要它是启动这部分的应用

为了实现这部分的功能,当前系统必须能启动其他应用程序进程的功能当那些部分它需要时,并且为这部分的java对象初始化这个java对象。

因此,不想在其他系统中的应用程序,android应用程序不需要一个单一的入口点(例如:

没有main())而是,提供了实例化和运行所需的必备组件。

Android有四大应用程序组件

1:

activity

一个Activity基类是为展示可视化用户接口。

例如:

一个Activity可以显示一个供用户选择的菜单列表,或者可以展示一些图片以及对应的说明。

一个短信的应用有一个活动显示发送消息的一系列的联系人,第二个活动去编写信息文本去选择联系人,第三个活动去查看以前的信息或修改一些设置。

虽然它们组成了一个聚的用户界面,每一个活动都和其他的的相互独立,每一个都继承Activity,是Activity的子类。

一个应用程序可以只有一个Activity,但是也可以有多个,比如刚刚提到的文本应用。

每个程序的作用,有多少个程序,取决于该应用的设计。

Services

Aservicedoesn'thaveavisualuserinterface,butratherrunsinthebackgroundforan

indefiniteperiodoftime.Forexample,aservicemightplaybackgroundmusicastheuserattendstoothermatters,oritmightfetchdataoverthenetworkorcalculatesomethingandprovidetheresulttoactivitiesthatneedit.EachserviceextendstheServicebaseclass.

2:

services

服务是android中一个在后台运行的应用程序,没有可视化的用户界面。

例如:

你可以在使用一个用户程序的同时播放背景音乐。

并且此时,播放音乐的代码就不需要和用户交互,因此可以作为一个服务来运行,并且使用用户服务的接口来实现音乐的播放,暂停,等功能。

对于不用向用户展示用户界面的情况下,使用服务是一个理想的选择。

如同其他的组件一样,services运行于应用程序进程的主线程。

所以它不会对其他组件或用户界面有任何的妨碍,他们一般会派生一个新线程来执行一些时间消耗型的任务。

Broadcastreceivers

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

Anapplicationcanhaveanynumberofbroadcastreceiverstorespondtoanyannouncementsitconsidersimportant.AllreceiversextendtheBroadcastReceiverbaseclass.Broadcastreceiversdonotdisplayauserinterface.However,theymaystartanactivityinresponsetotheinformationtheyreceive,ortheymayusetheNotificationManagertoalerttheuser.Notificationscangettheuser'sattentioninvariousways—flashingthebacklight,vibratingthedevice,playingasound,andsoon.Theytypicallyplaceapersistenticoninthestatusbar,whichuserscanopentogetthe

3:

Broadcastreceiver

broadcastreceiver是一个与注于接收广播通知信息并做出相应处理的组件。

许多广播是由系统代码产生的——例如通知时区改变、电池电量低、拍摄了一

照片或者用户改变了语言选项。

应用程序也可以发起广播——例如通知其它应用

程序一些数据已经下载到设备上并处于可用状态。

一个应用程序可以拥有任意数量的broadcastreceiver以对所有它认为重要的

通知信息予以响应。

所有的receiver均继承自BroadcastReceiver基类。

broadcastreceiver没有用户界面。

然而它们可以启动一个activity来响应它们

收到的信息或者也可以使用NotificationManager来通知用户。

通知可以用多种方

式来吸引用户的注意力──闪动背光灯、震动设备、播放声音等等。

通知一般是在

状态栏上放一个持续的图标用户可以打开它并获取消息。

Contentproviders

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

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

4:

容提供者contentprovider

contentprovider将一些特定的应用程序数据供给其它应用程序使用。

数据可以

存储于文件系统、SQLite数据库或其它有意义的方式。

contentprovider继承于

ContentProvider基类实现了一套使得其他应用程序能够检索和存储它所管理类

型数据的标准方法。

然而应用程序并不直接调用返些方法而是使用一个

ContentResolver对象调用它的方法作为替代。

ContentResolver可以与任何content

provider进行会话与其合作对任何相关的进程间通讯进行管理。

参阅独立的ContentProviders文档以获得更多关于使用contentprovider的信

息。

每当出现一个需要被特定组件处理的请求时Android会确保那个组件的应用

程序进程处于运行状态必要时会启动它并确保那个组件的一个合适的实例可必要时会创建那个实例。

 

 

ActivatingComponents

激活组件

Threeofthefourcomponenttypes—activities,services,andbroadcastreceivers—are

activatedbyanasynchronousmessagecalledan intent.Intentsbindindividualcomponentstoeachotheratruntime(youcanthinkofthemasthemessengersthatrequestanactionfromothercomponents),whetherthecomponentbelongstoyourapplicationoranother.

四种类型组件中的三种:

活动服务和广播接受者都通过一个叫做intent的异步消息激活。

这些intents在运行时(runtime)将这些属于你的程序或不同程序的单独的组件绑定在一起(bind),你可以把这些intents看作是需要其他组件的action的messengers。

 

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

一个Intent通过一个Intent对象建立,该Intent对象定义了一个消息去激活一个特殊的组件或一种特殊的组件--一个Intent既可以明确的说明也可以不明确,要分情况来看

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

对于活动和服务,一个Intent定义了一个动作去执行(比如:

要View或者send什么)和要操作数据的uri,一个Intent可能传递了为一个Activity传递了一个请求去展示一图片或者打开一个网页在这些例子中,你可以开始一个活动去接收结果,在这个例子中,这个Activity也可以返回这个通过一个Intent返回一个结果(例如,你可以发动一个Intent去让用户选择一个个人的contact并且返回给你,这个返回的意图包括一个指向这个联系人的URI)

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

对于广播接收者来说,intent只是简单的定义了要广播的容(比如,一个用以表明电池电量很低的广播仅包含了一个表明电池电量很低的字符串)。

Theothercomponenttype,contentprovider,isnotactivatedbyintents.Rather,itisactivatedwhentargetedbyarequestfroma ContentResolver.Thecontentresolverhandlesalldirecttransactionswiththecontentprovidersothatthecomponentthat'sperformingtransactionswiththeproviderdoesn'tneedtoandinsteadcallsmethodsonthe ContentResolver object.Thisleavesalayerofabstractionbetweenthecontentproviderandthecomponentrequestinginformation(forsecurity).

另外一个组件的类型,容提供者,不是通过意图激活。

而是由接收到contentResolver请激活的这个处理者处理所有的直接的事务通过容提供者。

因此,

Thereareseparatemethodsforactivatingeachtypeofcomponent:

这里有不同的方法来激活不同类型的组件

∙Youcanstartanactivity(orgiveitsomethingnewtodo)bypassingan Intent to startActivity() or startActivityForResult() (whenyouwanttheactivitytoreturnaresult).

∙你可启动一个一个活动(或者给他一些新的要做的容)通过传递一个Intent来startActiv

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

当前位置:首页 > 自然科学 > 物理

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

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