您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 有关android技术英文文献翻译
ApplicationFundamentalsAndroidapplicationsarewrittenintheJavaprogramminglanguage.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,andotheractivitiestoreviewoldmessagesorchange共21页第1页settings.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,但是也可以有多个,比如刚刚提到的文本应用。每个程序的作用,有多少个程序,取决于该应用的设计。ServicesAservicedoesn'thaveavisualuserinterface,butratherrunsinthebackgroundforanindefiniteperiodoftime.Forexample,aservicemightplaybackgroundmusicastheuserattendstoothermatters,oritmightfetchdataoverthenetworkorcalculatesomethingandprovidetheresulttoactivitiesthatneedit.EachserviceextendstheServicebaseclass.共21页第2页2:services服务是android中一个在后台运行的应用程序,没有可视化的用户界面。例如:你可以在使用一个用户程序的同时播放背景音乐。并且此时,播放音乐的代码就不需要和用户交互,因此可以作为一个服务来运行,并且使用用户服务的接口来实现音乐的播放,暂停,等功能。对于不用向用户展示用户界面的情况下,使用服务是一个理想的选择。如同其他的组件一样,services运行于应用程序进程的主线程内。所以它不会对其他组件或用户界面有任何的妨碍,他们一般会派生一个新线程来执行一些时间消耗型的任务。BroadcastreceiversAbroadcastreceiverisacomponentthatdoesnothingbutreceiveandreacttobroadcastannouncements.Manybroadcastsoriginateinsystemcode—forexample,announcementsthatthetimezonehaschanged,thatthebatteryislow,thatapicturehasbeentaken,orthattheuserchangedalanguagepreference.Applicationscanalsoinitiatebroadcasts—forexample,toletotherapplicationsknowthatsomedatahasbeendownloadedtothedeviceandisavailableforthemtouse.Anapplicationcanhaveanynumberofbroadcastreceiverstorespondtoanyannouncementsitconsidersimportant.AllreceiversextendtheBroadcastReceiverbaseclass.Broadcastreceiversdonotdisplayauserinterface.However,theymaystartanactivityinresponsetotheinformationtheyreceive,ortheymayusetheNotificationManagertoalerttheuser.Notificationscangettheuser'sattentioninvariousways—flashingthebacklight,vibratingthedevice,playingasound,andsoon.Theytypicallyplaceapersistenticoninthestatusbar,whichuserscanopentogetthe3:Broadcastreceiverbroadcastreceiver许多广播是由系统代码产生的——照片或者用户改变了语言选项。应用程序也可以发起广播——程序一些数据已经下载到设备上并处于可用状态。一个应用程序可以拥有任意数量的broadcastreceiver通知信息予以响应。所有的receiver均继承自BroadcastReceiver基类。broadcastreceiveractivity来响应它们NotificationManager来通知用户。通知可以用多种方共21页第3页式来吸引用户的注意力──闪动背光灯、震动设备、播放声音等等。通知一般是在ContentprovidersAcontentprovidermakesaspecificsetoftheapplication'sdataavailabletootherapplications.Thedatacanbestoredinthefilesystem,inanSQLitedatabase,orinanyothermannerthatmakessense.ThecontentproviderextendstheContentProviderbase
本文标题:有关android技术英文文献翻译
链接地址:https://www.777doc.com/doc-2067410 .html