版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、<p> 附錄二 外文文獻(xiàn)(原文)</p><p> The basic of description of android system</p><p> The mainstream of the next generation of open operating systems will not be on the desktop, but will appear i
2、n the phone that we carry every day. Open environment will lead these new applications may be integrated into these online services that already exist, of course, as with growing data services on mobile phones support th
3、e security flaws on the phone is also becoming increasingly clear. The nature of the next-generation operating system, whether to provide a complete integrated security pl</p><p> Android applications are w
4、ritten in the Java programming language.The compiled Java code — along with any data and resource files required by the application — is bundled by the apt tool into an Android package,an archive file marked by an .apk s
5、uffix.This file is the vehicle for distributing the application and installing it on mobile devices;it's the file users download to their devices.All the code in a single.apk file is considered to be one application.
6、</p><p> In many ways,each Android application lives in its own world:</p><p> By default,every application runs in its own Linux process.Android starts the process when any of the application
7、's code needs to be executed,and shuts down the process when it's no longer needed and system resources are required by other applications.</p><p> Each process has its own virtual machine(VM),so ap
8、plication code runs in isolation from the code of all other applications.</p><p> By default,each application is assigned a unique Linux user ID.Permissions are set so that the application's files are v
9、isible only to that user and only to the application itself — altough there are ways to export them to other applications as well.</p><p> It's possible to arrange for two applications to share the same
10、 user ID,in while case they will be able to see each other's files.To conserve system resources,applications with the same ID can also arrange to run in the same Linux process,sharing the same VM.</p><p>
11、; Application Components</p><p> A central feature of Android is that one application can make use of elements of other application (provided those application permit it).For example,if your application ne
12、eds to display a scrolling list of images and another application has developed a suitable scroller and made it available to others,you can call upon that scroller to do the work,rather than develop your own.Your applica
13、tion doesn't incorporate the code of the other application or link to it.Rather,it simply starts up that pie</p><p> For this to work,the system must be able to start an application process when any par
14、t of it is needed,and instantiate the Java objects for that part.Therefore,unlike applications on most other systems,Android applications don't have a single entry point for everything in the application(no main()fun
15、ction,for example).Rather,they have essential components that the system can instantiate and run as needed.There are four types of components:</p><p> Activities</p><p> An activity presents a
16、 visual user interface for one focused endeavor the user can undertake.For example,an activity might present a list of menu items users can choose from or it might display photographs along with their captions.A text mes
17、saging application might have one activity that shows a list of contacts to send messages to,a second activity to write the message to the chosen contact,and other activities to review old messages or change or change se
18、ttings.Tough they work together to for</p><p> An application might consist of just one activity or,like the text messaging application just mentioned,it may contain several.What the activities are,and how
19、many there are depends,of course,on the application and its design.Typically,one of the activities is marked as the first one that should be presented to the user when the application is launched.Moving from one activity
20、 to another is accomplished by having the current activity start the next one. </p><p> Each activity is given a default window to draw in.Typically,the window fills the screen,but it might be smaller than
21、the screen and float on top of other windows.An activity can also make use of additional windows — for example,a pop-up dialog that calls for a user response in the midst of the activity,or a window that presents users w
22、ith vital information when they select a particular item on-screen.</p><p> The visual content of the window is provided by a hierarchy of views — objects derived from the base View class.Each view controls
23、 a particular rectangular space within the window.Parent views contain and organize the layout of their children.Leaf views(those at the bottom of the hierarchy)draw in the rectangles they control and respond to user act
24、ions directed at that space.Thus,views are where the activity's interaction with the user takes place.</p><p> For example,a view might display a small image and initiate an action when the user taps th
25、at image.Android has a number of ready-made views that you can use — including buttons,text fields,scroll bars,menu items,check boxes,and more.</p><p> A view hierarchy is placed within an activity's wi
26、ndow by the Activity.setContentView()method.The content view is the View object at the root of the hierarchy.(See the separate User Interface document for more information on views and the hierarchy.)</p><p>
27、;<b> Services</b></p><p> A service doesn't have a visual user interface,but rather runs in the background for an indefinite period of time.For example,a service might play background music
28、 as the user attends to other matters,or it might fetch data over the network or calculate something and provide the result to activities that need it.Each service extends the Service base class.</p><p> A
29、prime example is a media player songs from a play list.The player application would probably have one or more activities that allow the user to choose songs and start playing them.However,the music playback itself would
30、bot be handled by an activity because users will expect the music to keep the music going,the media player activity could start a service to run in the background.The system would then keep the music playback service run
31、ning even after the activity that started it leaves the sc</p><p> It's possible to connect to (bind to)an ongoing service(and start the service if it's not already running).While connected,you can
32、communicate with the service through an interface that the service exposes.For the music service,this interface might allow users to pause,rewind,stop,and restart the playback.</p><p> Like activities and t
33、he other components,services run in the main thread of the application process.So that they won't block other components or the user interface,they often spawn another thread for time-consuming tasks(like music playb
34、ack).See Processes and Thread,later.</p><p> Broadcast receivers</p><p> A broadcast receiver is a component that does nothing but receive and react to broadcast announcements.Many broadcasts
35、originate in system code — for example,announcements that the timezone has changed,that the battery is low,that a picture has been taken,or that the user changed a language preference.Applications can also initiate broad
36、casts — for example,to let other applications know that some data has been downloaded to the device and is available for them to use.</p><p> An application can have any number of broadcast receivers to res
37、pond to respond to respond to any announcements it considers important.All receivers extend the BroadcastReceiver base class.</p><p> Broadcast receivers do not display a user interface.However,they may sta
38、rt an activity in response to the information they receive,or they may use the NotificationManager to alert the user.Notifications can get the user's attention in various ways — flashing the backlight,vibrating the d
39、evice,playing a sound,and so on,They typically place a persistent icon in the status bar,which users can open to get the message.</p><p> Content providers</p><p> A content provider makes a s
40、pecific set of the application's data available to other applications.The data can be stored in the file system,in an SQLite database,or in any other manner that makes sense.The content provider extends the ContentPr
41、ovider base class to implement a standard set of methods that enable other applications to retrieve and store data of the type it controls.However,applications do not call these methods directly.Rather they use a Content
42、Resolver object and call its methods</p><p> See the separate Content Providers document for more information on using content providers.</p><p> Whenever there's a request that should be
43、handled by a particular component,Android makes sure that the application process of the component is running,starting it if necessary,and that an appropriate instance of the component is available,creating the instance
44、if necessary.</p><p> Activating components:intents</p><p> Content providers are activated when they're targeted by a request from a ContentResolver.The other three components — activitie
45、s,services,and broadcast receivers — are activated by asynchronous messages called intents.An intent is an Intent object that holds the content of the message.For activities and services,it names the action being request
46、ed and specifies the URI of the data to act on,among other things.For example,it might convey a request for an activity to present an image t the user o</p><p> There are separate methods for activating eac
47、h type of component:</p><p> 1.An activity is launched(or given something new to do)by passing an Intent object to Context.startActivity() or Activity.startActivityForResult().The responding activity can lo
48、ok at the initial intent that caused it to be launched by calling its getIntent() method.Android calls the activity's onNewIntent()method to pass it any subsequent intents.One activity often starts the next one.If it
49、 expects a result back from the activity it's starting,it calls startActivityForResult() instead of startAc</p><p> 2.A service is started(or new instructions are given to an ongoing service)by passing
50、an Intent object to Context.startService().Android calls the service's onStart() method and passes it the Intent object.Similarly,an intent can be passed to Context.bindService() to establish an ongoing connection be
51、tween the calling component and a target service.The service receives the Intent object in an onBind() call.(If the service is not already running,bindService() can optionally start it.)For example,</p><p>
52、 A later section,Remote procedure calls,has more details about binding to a service.</p><p> 3.An application can initiate a broadcast by passing an Intent object to methods like Context.sendStickyBroadcast
53、() in any of their variations.Android delivers the intent to all interested broadcast receivers by calling their onReceive() methods.For more on intent messages,see the separate article,Intents and Intent Filters.</p&
54、gt;<p> Shutting down components</p><p> A content provider is active only while it's responding to a request from a ContentResolver.And a broadcast receiver is active only while it's respon
55、ding to a broadcast message.So there's no need to explicitly shut down these components.Activities,on the other hand,provide the user interface.They're in a long-running conversation with the user and may remain
56、active,even when idle,as long time.So Android has methods to shut down activities and services in an orderly way:</p><p> 1.An activity can be shut down by calling its finish() method.Onte activity can shut
57、 down another activity (one it started with startActivityForResult())by calling finishActivity().</p><p> 2.A service can be stopped by calling its stopSelf() method,or by calling Context.stopService().<
58、/p><p> Components might also be shut down by the system when they are no longer being used or when Android must reclaim memory for more active components.A later section,Component Lifecycles,discusses this po
59、ssibility and its ramifications in more detail.</p><p> The manifest file</p><p> Before Android can start an application component,it must learn that the component exists.Therefore,applicatio
60、ns declare their components in a manifest file that's bundled into the Android package,the .apk file that also holds the application's code,files, and resources.</p><p> The manifest is a structured
61、 XML file and is always named AndroidManifest.xml for all applications.It does a number of things in addition to declaring the application's components,such as naming any libraries the application needs to be linked
62、against(besides the default Android library)and identifying any permissions the application expects to be granted.</p><p> But the principal task of the manifest is to inform Android about the application
63、39;s components.For example,an activity might be declared as follows:</p><p> The name attribute of the <activity>element names the Activity subclass that implements the activity.The icon and label at
64、tributes point to resource files containing an icon and label that can be displayed to users to resource files containing an icon and label that can be displayed to users to represent the activity.</p><p>
65、 The other components are declared in a similar way — <service>elements for services,<receiver>elements for broadcast receivers,and<provider>elements for content providers.Activities,services,and conten
66、t providers that are not declared in the manifest are not visible to the system and are consequently never run.However,broadcast receivers can either be declared in the manifest,or they can be created dynamically i code
67、(as BroadcastReceiver objects)and registered with the system by calling Context</p><p> For more on how to structure a manifest file for your application,see The Android Manifest.xml File.</p><p&
68、gt; Intent filters</p><p> An Intent object can explicitly name a target component.If it does,Android finds that component(based on the declarations in the manifest file)and activates it.But if a target is
69、 not explicitly named,Android must locate the best component to respond to the intent.It does s by comparing the Intent object to the intent filters of potential targets.A component's intent filters inform Android of
70、 the kinds of intents the component is able to handle.Like other essential information about the component</p><p> The first filter in the example — the combination of the action "android.intent.action
71、.MAIN"and the category "android.intent.category.LAUNCHER"—is a common one.It marks the activity as one that should be represented in the application launcher,the screen listing applications users can launc
72、h on the device.In other words,the activity is the entry point for the application,the initial one users would see when they choose the application in the launcher.</p><p> The component can have any number
73、 of intent filters,each one declaring a different set of capabilities.If it doesn't have any filters,it can be activated only by intents that explicitly name the component as the target.</p><p> For a b
74、roadcast receiver that's created and registered in code,the intent filter is instantiated directly as an IntentFilter object.All other filters are set up in the manifest.</p><p> For more on intent filt
75、ers,see a separate document, Intents and Intent Filters.</p><p> 附錄三 外文文獻(xiàn)(譯文)</p><p><b> 安卓系統(tǒng)的基本描述</b></p><p> 下一代開(kāi)放操作系統(tǒng)的主流將不會(huì)在桌面上,但是將會(huì)出現(xiàn)在我們每天攜帶的手機(jī)上。這些開(kāi)放性的環(huán)境將會(huì)帶領(lǐng)這些新的應(yīng)
76、用可能集成這些已經(jīng)存在的在線服務(wù),當(dāng)然隨著日以具增的數(shù)據(jù)與服務(wù)在手機(jī)上的支持,手機(jī)上的安全缺陷也越發(fā)明顯。下一代操作系統(tǒng)本質(zhì)在于是否提供一個(gè)完整綜合的安全平臺(tái)。</p><p> 由開(kāi)放手機(jī)聯(lián)盟(open Handset Alliance 谷歌領(lǐng)導(dǎo))所開(kāi)發(fā)的android 系統(tǒng)是一個(gè)被廣泛看好的一個(gè)手機(jī)開(kāi)源系統(tǒng),該系統(tǒng)提供一個(gè)基本的操作系統(tǒng),一個(gè)中間件應(yīng)用層,一個(gè)java開(kāi)發(fā)工具和一個(gè)系統(tǒng)應(yīng)用收集器(colle
77、ction of system applications)。盡管android SDK自2007年就發(fā)布了,但是第一部android 手機(jī)卻在2008年10月才誕生。自從這時(shí)起谷歌開(kāi)起了自己的時(shí)代,T-Mobile的G1的制造商臺(tái)灣 HTC估算G1的發(fā)貨量在2008年底已經(jīng)超過(guò)100萬(wàn)部。據(jù)業(yè)內(nèi)人士預(yù)期該G1手機(jī)的銷量將會(huì)在2009年繼續(xù)保持。不久的將來(lái)其他許多手機(jī)供應(yīng)商要計(jì)劃支持這個(gè)系統(tǒng)。</p><p>
78、一個(gè)圍繞android龐大的開(kāi)發(fā)者社區(qū)已經(jīng)建立,同時(shí)很多新的產(chǎn)品和應(yīng)用已經(jīng)可以在android上使用。一個(gè)Android的主要賣點(diǎn)是它使開(kāi)發(fā)人員無(wú)縫把在線服務(wù)擴(kuò)展到手機(jī)。這方面最明顯的例子是谷歌的緊密集成Gmail,日歷和聯(lián)系人Web應(yīng)用程序通過(guò)該系統(tǒng)。用戶只需提供一個(gè)android用戶名和密碼,其手機(jī)自動(dòng)同步與谷歌的服務(wù)。其他廠商正在迅速適應(yīng)自己的現(xiàn)有的即時(shí)通訊,社交網(wǎng)絡(luò)和游戲服務(wù)。Android和許多企業(yè)尋找新途徑來(lái)整合他們的自己已
79、有的業(yè)務(wù)到android上。</p><p> 傳統(tǒng)的臺(tái)式機(jī)和服務(wù)器的操作系統(tǒng)一直在努力進(jìn)行安全功能的集成。這些個(gè)人和商業(yè)應(yīng)用在單一平臺(tái)的很出色,然而這一塊業(yè)務(wù)一個(gè)手機(jī)平臺(tái)上像android上不是很有用。它給了許多研究人員希望。Android沒(méi)有停在為其他平臺(tái)體用應(yīng)用支持:應(yīng)用的執(zhí)行依賴于頂層JAVA中間件,這個(gè)中間件運(yùn)行在嵌入式Linux 內(nèi)核之上。所以開(kāi)發(fā)人員要把他們的應(yīng)用部署到Android必須使用其自定
80、義的用戶界面環(huán)境。</p><p> 此外,android系統(tǒng)應(yīng)用限制各應(yīng)用相互調(diào)用API協(xié)作,并且對(duì)方為自己的用戶應(yīng)用進(jìn)行身份驗(yàn)證。盡管這些應(yīng)用有一定的安全特性,我們一些有經(jīng)驗(yàn)的開(kāi)發(fā)人員開(kāi)發(fā)android應(yīng)用人士透露,設(shè)計(jì)安全應(yīng)用程序并不總是直線前進(jìn)的。Android使用一個(gè)簡(jiǎn)單的許可標(biāo)簽分配模式限制訪問(wèn)的資源,但其他應(yīng)用程序的原因必要性和便利,其設(shè)計(jì)師們?cè)黾恿死Щ髮?duì)這個(gè)系統(tǒng)。本文試圖對(duì)Android的安全的
81、復(fù)雜性進(jìn)行講解,并注意一些可能的發(fā)展缺陷以及應(yīng)用程序的安全。我們通過(guò)嘗試得出一些經(jīng)驗(yàn)教訓(xùn),希望對(duì)未來(lái)的安全有用。</p><p> Android應(yīng)用程序框架對(duì)開(kāi)發(fā)者來(lái)說(shuō)是一個(gè)強(qiáng)制架構(gòu)。它沒(méi)有一個(gè)main()函數(shù)功能或單一入口點(diǎn)執(zhí)行,相反,開(kāi)發(fā)人員必須在設(shè)計(jì)方面的應(yīng)用組件。我們開(kāi)發(fā)的應(yīng)用對(duì)android的sdk的幫助的API</p><p> Android系統(tǒng)定義了4種組件類型。&l
82、t;/p><p> Activity 組件定義應(yīng)用程序的用戶界面。通常,應(yīng)用程序開(kāi)發(fā)者定義每一個(gè)活動(dòng)“畫面?!盇ctivity可以自己開(kāi)始,也可能通過(guò)傳遞和返回值。在一時(shí)間只有一個(gè)鍵盤的系統(tǒng)Activity可以進(jìn)行處理,在這個(gè)時(shí)候所有其他的Activity都會(huì)被暫停。</p><p> Service組件執(zhí)行后臺(tái)處理。當(dāng)一個(gè)活動(dòng)需要進(jìn)行一些操作,在用戶界面消失以后(如下載一個(gè)文件或播放音樂(lè)
83、),它通常采取此種動(dòng)作特殊設(shè)計(jì)的服務(wù)。開(kāi)發(fā)人員還可以在系統(tǒng)啟動(dòng)使用特殊的守護(hù)進(jìn)程,Service通常定義一個(gè)遠(yuǎn)程過(guò)程調(diào)用(RPC),其他系統(tǒng)組件可以用來(lái)傳送接口命令和檢索數(shù)據(jù),以及注冊(cè)一個(gè)回調(diào)函數(shù)。</p><p> ContentProvider組件存儲(chǔ)和共享數(shù)據(jù) 用關(guān)系數(shù)據(jù)庫(kù)接口。每個(gè)Content供應(yīng)者都有一個(gè)關(guān)聯(lián)的“權(quán)限”來(lái)形容它的內(nèi)容包含。其他組件使用時(shí)作為一個(gè)handle執(zhí)行SQL查詢(如SELEC
84、T,INSERT或DELETE內(nèi)容。雖然Content供應(yīng)者通常存儲(chǔ)把數(shù)值放在數(shù)據(jù)庫(kù)記錄中,數(shù)據(jù)檢索是實(shí)現(xiàn)特殊的例子,文件也同時(shí)通過(guò)內(nèi)容提供商共享接口。</p><p> Broadcast receiver該組件作為為從郵件信箱發(fā)送信息給他應(yīng)用程序。通常,廣播消息的應(yīng)用程序代碼隱含的目的地。因此,廣播接收器訂閱這些目的地接收發(fā)送給它的消息。應(yīng)用程序代碼也可以解決明確廣播接收機(jī)包括命名空間分配。</p&g
85、t;<p> Component Interaction該組件交互的主要機(jī)制是一個(gè)intent ,這是一個(gè)簡(jiǎn)單的消息對(duì)象,其中包含一個(gè)目的地組件的地址和數(shù)據(jù)。 Android的API定義了他的方法中傳入intent ,并使用該信息來(lái)啟動(dòng)一個(gè)activity例如開(kāi)始一個(gè)activity(startActivity(intent)),啟動(dòng)服務(wù)(startService(intent))和廣播信息(sendBroadcast(
86、intent))。Android框架來(lái)通知這些方法的調(diào)用開(kāi)始執(zhí)行在目標(biāo)應(yīng)用程序代碼。這個(gè)過(guò)程中內(nèi)部組件通信稱為一個(gè)動(dòng)作。簡(jiǎn)單地說(shuō), Intent對(duì)象定義的“Intent”以執(zhí)行“action”。Android的一個(gè)最強(qiáng)大的特點(diǎn)是允許的多種intent尋址機(jī)制。開(kāi)發(fā)人員可以解決一個(gè)目標(biāo)組件使用其應(yīng)用的空間,他們也可以指定一個(gè)隱含的名稱。在后一種情況下,系統(tǒng)決定了一個(gè)action的最佳組件,通過(guò)考慮安裝的應(yīng)用程序和用戶的選擇 。</p
87、><p> 這個(gè)隱含的名字被稱為動(dòng)作字符串因?yàn)樗厥獾念愋偷恼?qǐng)求動(dòng)作。例如一個(gè)view動(dòng)作字符串,在一個(gè)intent中和數(shù)據(jù)域指向一個(gè)圖像文件,系統(tǒng)將會(huì)直接指首選圖像瀏覽器。</p><p> 開(kāi)發(fā)者也能使用動(dòng)作字符串進(jìn)行大量廣播發(fā)送和接收。在接收端的接收者,開(kāi)發(fā)者使用一intent 過(guò)濾器來(lái)定制特殊的動(dòng)作字符串。Android系包括附加目標(biāo)的決議規(guī)則,但可選的數(shù)據(jù)操作字符串類型是最常見(jiàn)的
88、。</p><p> Android應(yīng)用程序使用Java編程語(yǔ)言開(kāi)發(fā)。apt工具吧編譯后的Java代碼連同應(yīng)用程序所需的其他數(shù)據(jù)和資源文件一起打包到一個(gè)Android包文件中,這個(gè)文件使用.apk作為擴(kuò)展名。此文件是分發(fā)并安裝應(yīng)用程序到移動(dòng)設(shè)備的載體;是用戶下載到他們的設(shè)備的文件。單一.apk文件中的所有代碼被認(rèn)為是一個(gè)應(yīng)用程序。</p><p> 從多個(gè)角度來(lái)看,每個(gè)Android應(yīng)
89、用程序都存在于它自己的世界之中:</p><p> 默認(rèn)情況下,每個(gè)應(yīng)用程序均運(yùn)行于它自己的Linux進(jìn)程中。當(dāng)應(yīng)用程序中的任何代碼需要被執(zhí)行時(shí),Android啟動(dòng)此進(jìn)程,而當(dāng)不再需要此進(jìn)程并且其它應(yīng)用程序又請(qǐng)求系統(tǒng)資源時(shí),則關(guān)閉這個(gè)進(jìn)程。</p><p> 每個(gè)進(jìn)程都有其獨(dú)有的虛擬機(jī)(VM),所以應(yīng)用程序代碼與其它應(yīng)用程序代碼是隔離運(yùn)行的。</p><p>
90、 默認(rèn)情況下,每個(gè)應(yīng)用程序均被賦予一個(gè)唯一的Linux用戶ID,并加以權(quán)限設(shè)置,使得應(yīng)用程序的文件僅對(duì)此用戶及此應(yīng)用程序可見(jiàn)—盡管也有其它的方法使得這些文件同樣能為其他應(yīng)用程序訪問(wèn)。</p><p><b> 應(yīng)用程序組件</b></p><p> Android的一個(gè)核心特性就是一個(gè)應(yīng)用程序可以使用其它應(yīng)用程序的元素(如果那個(gè)應(yīng)用程序允許的話)。例如,如果你的應(yīng)
91、用程序需要顯示一個(gè)圖片卷動(dòng)列表,而另一個(gè)應(yīng)用程序已經(jīng)開(kāi)發(fā)了一個(gè)合用的而又允許別的應(yīng)用程序使用的話,你可以直接調(diào)用那個(gè)卷動(dòng)列表來(lái)完成工作,而不用自己再開(kāi)發(fā)一個(gè)。你的應(yīng)用程序并沒(méi)有吸納或鏈接其它應(yīng)用程序的代碼。它只是在有需求的時(shí)候啟動(dòng)了其它應(yīng)用程序的那個(gè)功能部分。</p><p> 為達(dá)到這個(gè)目的,系統(tǒng)必須能夠在一個(gè)應(yīng)用程序的任何一部分被需要時(shí)啟動(dòng)一個(gè)此應(yīng)用程序的進(jìn)程,并將那個(gè)部分的Java對(duì)象實(shí)例化。因此,不像其
92、它大多數(shù)系統(tǒng)上的應(yīng)用程序,Android應(yīng)用程序并沒(méi)有為應(yīng)用程序提供一個(gè)單獨(dú)的入口點(diǎn)(比如說(shuō),沒(méi)有main()函數(shù)),而是為系統(tǒng)提供了可以實(shí)例化和運(yùn)行所需要的必備組件。一共四種組件類型:</p><p><b> Activity</b></p><p> Activity是為用戶操作而展示的可視化用戶界面。例如,一個(gè)activity可以展示一個(gè)菜單項(xiàng)列表供用戶選
93、擇,接著顯示一些包含說(shuō)明文字的照片。一個(gè)短消息應(yīng)用程序可以包括一個(gè)用于顯示要發(fā)送消息到的聯(lián)系人列表的activity,一個(gè)給選定的聯(lián)系人寫短信的activity以及翻閱以前的短信或改變?cè)O(shè)置的其他activity。盡管它們一起組成了一個(gè)內(nèi)聚的用戶界面,但其中每個(gè)activity都不與其它的保持獨(dú)立。每一個(gè)都實(shí)現(xiàn)為以Activity類為基類的子類。</p><p> 一個(gè)應(yīng)用程序可以只有一個(gè)activity,或者,
94、如剛才提到的短信應(yīng)用程序那樣,包含很多個(gè)。每個(gè)activity的作用,以及有多少個(gè)activity,當(dāng)然是取決于應(yīng)用程序及其設(shè)計(jì)的。一般情況下,總有一個(gè)應(yīng)用程序被標(biāo)記為用戶在應(yīng)用程序啟動(dòng)的時(shí)候第一個(gè)看到的。從一個(gè)activity轉(zhuǎn)向另一個(gè)activity靠的是用當(dāng)前的activity啟動(dòng)下一個(gè)。</p><p> 每個(gè)activity都被給予一個(gè)默認(rèn)的窗口以進(jìn)行繪制。一般情況下,這個(gè)窗口是滿屏的,但它也可以是一
95、個(gè)小的位于其它窗口之上的浮動(dòng)窗口。一個(gè)activity也可以使用附加窗口—例如,一個(gè)在activity運(yùn)行過(guò)程中彈出的供用戶響應(yīng)的對(duì)話框,或是一個(gè)當(dāng)用戶選擇了屏幕上特定項(xiàng)目后顯示的必要信息的窗口。</p><p> 窗口顯示的可視內(nèi)容是由一系列層次化view構(gòu)成的,這些view均繼承自View基類。每個(gè)view均控制著窗口中一塊特定的矩形區(qū)域中進(jìn)行繪制,并對(duì)用戶直達(dá)其區(qū)域的操作做出響應(yīng)。因此,view是acti
96、vity與用戶進(jìn)行交互的界面。例如,view可以顯示一個(gè)小圖片,并在用戶指定它的時(shí)候產(chǎn)生動(dòng)作。Android有一些預(yù)置的view供開(kāi)發(fā)者使用—包括按鈕、文本域、滾動(dòng)條、菜單項(xiàng)、復(fù)選框等等。</p><p> view層次結(jié)構(gòu)是由Activity.setContentView()方法放入activity的窗口之中的。content view是位于層次結(jié)構(gòu)根位置的View對(duì)象。(參見(jiàn)獨(dú)立的用戶界面文檔以讀取關(guān)于vi
97、ew及層次結(jié)構(gòu)的更多信息。)</p><p><b> 2.Service</b></p><p> Service沒(méi)有可視化的用戶界面,而是在一段時(shí)間內(nèi)在后臺(tái)運(yùn)行,例如,一個(gè)service可以在用戶做其它事情的時(shí)候在后臺(tái)播放背景音樂(lè)、從網(wǎng)絡(luò)上獲取數(shù)據(jù)或者計(jì)算一些東西并提供給需要這個(gè)運(yùn)算結(jié)果的activity使用。每個(gè)service都繼承自Service基類。&l
98、t;/p><p> 一個(gè)媒體播放器播放列表中的曲目是一個(gè)不錯(cuò)的例子。播放器應(yīng)用程序可能有一個(gè)或多個(gè)activity來(lái)給用戶選擇歌曲并進(jìn)行播放。然而,音樂(lè)播放這個(gè)任務(wù)本身應(yīng)該由任何activity來(lái)處理,因?yàn)橛脩羝谕词乖谒麄冸x開(kāi)播放器應(yīng)用程序而開(kāi)始做別的事情時(shí),音樂(lè)仍在繼續(xù)播放。為達(dá)到這個(gè)目的,媒體播放器activity可以啟動(dòng)一個(gè)運(yùn)行于后臺(tái)的service。系統(tǒng)將在這個(gè)activity不再顯示于屏幕后,仍維持音樂(lè)
99、播放service的運(yùn)行。</p><p> 連接至(綁定到)一個(gè)正在運(yùn)行的service(如果service沒(méi)有運(yùn)行,則啟動(dòng)之)是可能的。連接之后,你可以通過(guò)那個(gè)service暴露出來(lái)的接口不service進(jìn)行通訊。對(duì)于音樂(lè)service來(lái)說(shuō),這個(gè)接口可以允許用戶暫停、回退、停止以及重新開(kāi)始播放。</p><p> 如同activity和其它組件一樣,service運(yùn)行于應(yīng)用程序進(jìn)程
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 安卓系統(tǒng)外文翻譯
- 安卓開(kāi)發(fā)外文翻譯--安卓應(yīng)用基礎(chǔ)
- [雙語(yǔ)翻譯]安卓外文翻譯--安卓操作系統(tǒng)的防盜云應(yīng)用
- [雙語(yǔ)翻譯]安卓外文翻譯--安卓操作系統(tǒng)的防盜云應(yīng)用(英文)
- [雙語(yǔ)翻譯]安卓外文翻譯--安卓操作系統(tǒng)的防盜云應(yīng)用中英全
- 安卓系統(tǒng)的安全性外文翻譯
- 2014年安卓外文翻譯--安卓操作系統(tǒng)的防盜云應(yīng)用
- 2014年安卓外文翻譯--安卓操作系統(tǒng)的防盜云應(yīng)用.DOCX
- 2014年安卓外文翻譯--安卓操作系統(tǒng)的防盜云應(yīng)用(英文).PDF
- 手機(jī)系統(tǒng)外文翻譯---深入理解安卓系統(tǒng)的安全性
- 手機(jī)系統(tǒng)外文翻譯---深入理解安卓系統(tǒng)的安全性
- 手機(jī)系統(tǒng)外文翻譯---深入理解安卓系統(tǒng)的安全性
- android點(diǎn)菜軟件外文翻譯--基于安卓系統(tǒng)的電子菜單軟件
- android外文翻譯--外文翻譯--在安卓平臺(tái)的擊鍵動(dòng)力學(xué)
- android外文翻譯--深入理解安卓系統(tǒng)的安全性
- android點(diǎn)菜軟件外文翻譯--基于安卓系統(tǒng)的電子菜單軟件
- android點(diǎn)菜軟件外文翻譯--基于安卓系統(tǒng)的電子菜單軟件
- android點(diǎn)菜軟件外文翻譯--基于安卓系統(tǒng)的電子菜單軟件
- 安卓應(yīng)用基礎(chǔ)畢業(yè)論文外文翻譯
- [雙語(yǔ)翻譯]--安卓外文翻譯--android與ios安全之戰(zhàn)
評(píng)論
0/150
提交評(píng)論