外文翻译安卓系统的大体描述

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

附录二外文文献(原文)
The basic of description of android system The mainstream of the next generation of open operating systems will not be on the desktop, but will appear in 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 the 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 platform.
By the Open Mobile Alliance (open Handset Alliance led by Google) developed the android system is a widely optimistic about an open source phone system, the system provides a basic operating system, a middle ware application layer, a java development tools and a system Application collector (collection of system applications). The android the SDK since 2007 on the release of the first android phone in October 2020 before the birth. Google opened since then on his own time, Taiwan's HTC, the manufacturer of the T-Mobile G1 estimate G1 shipments have more than one million at the end of 2020. According to industry insiders expect the G1 mobile phone sales in 2020 continue. Many other mobile phone suppliers in the near future plans to support this system.
Around an android and a huge developer community has been
established, while a lot of new products and applications on the android. Android's main selling point is that it enables developers to seamlessly expand online services to mobile phones. This is the most obvious example is Google's tightly integrated with Gmail, Calendar and Contacts Web applications through the system. Users only need to provide an android user name and password, the phone automatically sync with Google services. The other vendors are quickly adapt their existing instant messaging, social networking and gaming services. Android and many companies find new ways to integrate their existing business to the android.
Traditional desktop and server operating system has been working for the integration of security features. These individuals and business applications on a single platform is very good, however a business phone platform like android is not very useful. It gives the hope of many researchers. Android is not parked in the body for other platform application support: the implementation of the application depends on a top-level JAVA middle ware, the middle ware running on the embedded Linux kernel. Therefore, developers should deploy their applications to the Android must use a custom user interface environment.
In addition, the android system applications limit the application to call each other API collaboration, and the other to authenticate the user application. Although these applications have certain safety features,
some of our experienced developers to create Android applications who revealed that the design of security applications is not always straight forward. Android uses a simple permission label distribution mode to restrict access to resources, but the reasons for the necessity and convenience of other applications, the designers have increased the confusion on this system. This paper attempts to explain the complexity of the Android security, and pay attention to some of the possible development defects and application security. We try to draw some lessons learned, and hope that the safety of the future.
Android application framework for developers is a mandatory framework. It does not have a main () function function or a single entry point for the implementation of the contrary, the developer must in the design of application components. We developed applications to help the API of the android sdk
The Android system defines four kinds of component type.
Activity component that defines the application user interface. Usually, the application developer defines each activity screen. Activity can start, it may pass and return values. Can be handled at a time only a keyboard system Activity, all other Activity will be suspended at this time.
Service components perform background processing. The need for some operations when an activity, after the disappearance of the user interface (such as downloading a file or playing music), it usually take
such action specially designed services. Developers can also use a special daemon at system startup, the service is usually defined a remote procedure call (RPC), and other system components can be used to send the interface command and retrieve data, as well as to register a callback function.
ContentProvider component storage and share data with relational database interfaces. Each Content supplier has an associated "rights" to describe its contents contains. Other components when used as a handle to execute SQL queries (eg SELECT, INSERT, or DELETE content. Content suppliers are typically stored the values on the database records, data retrieval is a special case, the file is also shared by the content provider interface.
The components of the broadcast receiver as to send a message from the mailbox to the application. Typically, the broadcast message, the application code implicit destination. Therefore, the radio receiver subscribe to these destinations receive messages sent to it. The application code can also be solved explicitly broadcast receivers, including the name space allocation.
The main mechanism of the interaction of the components of the Component Interaction, is an intent, which is a simple message object, which contains a destination address and data components. The Android API defines his approach into intent, and use that information to initiate
an activity such as start an activity (startActivity (An intent)) start services (the startService (An intent)) and radio (sendBroadcast (An intent)). Android framework to inform the calls to these methods began to perform in the target application code. This process, the internal components of communication is called an action. Simply put, the Intent object defined in the "Intent to implement the" action ". One of the most powerful features of the Android is allowed a variety of intent addressing mechanism. The developer can solve the space of a target component using its applications, they can also specify an implicit name. In the latter case, the system determines the best components of an action by considering the installed applications and user choice.
Implicit name is called the action string because of his special type of the requested action. Such as a view action string, in an intent data field points to an image file, the system will directly referring to the preferred image viewer.
Developers can also use the action string a large number of radio to send and receive. Receiver at the receiving end, the developers use an intent filter to customize the special action string. Android Department, including the additional goal of the resolution rules, but an optional string type of data manipulation is the most common.
Android applications are written 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 suffix.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.
In many ways,each Android application lives in its own world:
(1)By default,every application runs in its own Linux process.Android starts the process when any of the application'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.
(2)Each process has its own virtual machine(VM),so application code runs in isolation from the code of all other applications.
(3)By default,each application is assigned a unique Linux user ID.Permissions are set so that the application's files are visible only to that user and only to the application itself —altough there are ways to export them to other applications as well.
It's possible to arrange for two applications to share the same 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.
Application Components
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 needs 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 application doesn't incorporate the code of the other application or link to it.Rather,it simply starts up that piece of the other application when the need arises.
For this to work,the system must be able to start an application process when any part 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()function,for example).Rather,they have essential components that the system can instantiate and run as needed.There are four types of components:
Activities
An activity presents a 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 messaging 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 settings.Tough they work
together to form a cohesive user interface,each activity is independent of the others.Each one is implemented as a subclass of the Activity base class.
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 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 to another is accomplished by having the current activity start the next one.
Each activity is given a default window to draw in.Typically,the window fills the screen,but it might be smaller than 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 with vital information when they select a particular item on-screen.
The visual content of the window is provided by a hierarchy of views —objects derived from the base View class.Each view controls 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 actions directed at that space.Thus,views are where the activity's
interaction with the user takes place.
For example,a view might display a small image and initiate an action when the user taps that 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.
A view hierarchy is placed within an activity's window 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.)
Services
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 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.
A 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 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 running even after the activity that started it leaves the screen.
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 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.
Like activities and the 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 playback).See Processes and Thread,later.
Broadcast receivers
A broadcast receiver is a component that does nothing but receive and react to broadcast announcements.Many broadcasts 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 broadcasts — for example,to let other applications know that some data has been downloaded to the device and is available for them to use.
An application can have any number of broadcast receivers to respond to respond to respond to any announcements it considers important.All receivers extend the BroadcastReceiver base class.
Broadcast receivers do not display a user interface.However,they may start 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 device,playing a sound,and so on,They typically place a persistent icon in the status bar,which users can open to get the message.
Content providers
A content provider makes a specific 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 ContentProvider 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 ContentResolver object and call its methods instead.A ContentResolver can talk to any content provider;it cooperates with the provider to manage any interprocess communication that's involved.
See the separate Content Providers document for more information on using content providers.
Whenever there's a request that should be 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 if necessary.
Activating components:intents
Content providers are activated when they're targeted by a request from a ContentResolver.The other three components —activities,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 requested 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 or let the user edit some text.For broadcast receivers,the Intent object names the action being announced.For example,it might announce to interested parties that the camera button has been pressed.
There are separate methods for activating each type of component:
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 look 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 expects a result back from the activity it's starting,it calls startActivityForResult() instead of startActivity().For example,if it starts an activity that lets the user pick a photo,it might expect to be returned the chosen photo.The result is returned in an Intent object that's passed to the calling activity's onActivityResult() method.
2.A service is started(or new instructions are given to an ongoing service)by passing 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 between 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,an activity might establish a connection with the music playback service mentioned earlier so that it can provide the user with the means(a user interface)for controlling the playback.The activity would call bindService() to set up that connection,and then call methods defined by the service to affect the playback.
A later section,Remote procedure calls,has more details about binding to a service.
3.An application can initiate a broadcast by passing an Intent object to methods like Context.sendStickyBroadcast() 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.
Shutting down components
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 responding 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 active,even when idle,as long time.So Android has methods to shut down activities and services in an orderly way:
1.An activity can be shut down by calling its finish() method.Onte activity can shut down another activity (one it started with startActivityForResult())by calling finishActivity().
2.A service can be stopped by calling its stopSelf() method,or by calling Context.stopService().
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 possibility and its ramifications in more detail.
The manifest file
Before Android can start an application component,it must learn that the component exists.Therefore,applications 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.
The manifest is a structured 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 against(besides the default Android library)and identifying any permissions the application expects to be granted.
But the principal task of the manifest is to inform Android about the application's components.For example,an activity might be declared as follows:
The name attribute of the <activity>element names the Activity subclass that implements the activity.The icon and label attributes 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.
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 content 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 (as BroadcastReceiver objects)and registered with the system by calling Context.registerReceiber().
For more on how to structure a manifest file for your application,see The Android Manifest.xml File.
Intent filters
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 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 the kinds of intents the component is able to handle.Like other essential information about the component,they're declared in the manifest.Here's an extension of the previous example that adds two intent filters to the activity:
The first filter in the example — the combination of the action "android.intent.action.MAIN"and the category "UNCHER"—is a common one.It marks the activity as one that should be represented in the application launcher,the
screen listing applications users can launch 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.
The component can have any number 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.
For a broadcast 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.
For more on intent filters,see a separate document, Intents and Intent Filters.
附录三外文文献(译文)
安卓系统的大体描述
下一代开放操作系统的主流将可不能在桌面上,可是将会出此刻咱们天天携带的电话上。

这些开放性的环境将会率领这些新的应用可能集成这些已经存在的在线效劳,固然随着日以具增的数据与效劳在电话上的支持,电话上的平安缺点
也越发明显。

下一代操作系统本质在于是不是提供一个完整综合的平安平台。

由开放电话联盟(open Handset Alliance 谷歌领导)所开发的android 系统是一个被普遍看好的一个电话开源系统,该系统提供一个大体的操作系统,一个中间件应用层,一个java开发工具和一个系统应用搜集器(collection of system applications)。

尽管android SDK自2007年就发布了,可是第一部android 电话却在2020年10月才诞生。

自从这时起谷歌开起了自己的时期,T-Mobile的G1的制造商台湾 HTC估算G1的发货量在2020年末已经超过100万部。

据业内人士预期该G1电话的销量将会在2020年继续维持。

不久的以后其他许多电话供给商要打算支持那个系统。

一个围绕android庞大的开发者社区已经成立,同时很多新的产品和应用已经能够在android上利用。

一个Android的要紧卖点是它使开发人员无缝把在线效劳扩展得电话。

这方面最明显的例子是谷歌的紧密集成Gmail,日历和联系人Web应用程序通过该系统。

用户只需提供一个android用户名和密码,其电话自动同步与谷歌的效劳。

其他厂商正在迅速适应自己的现有的即时通信,社交网络和游戏效劳。

Android和许多企业寻觅新途径来整合他们的自己已有的业务到android上。

传统的台式机和效劳器的操作系统一直在尽力进行平安功能的集成。

这些个人和商业应用在单一平台的很超卓,但是这一块业务一个电话平台上像android 上不是很有效。

它给了许多研究人员希望。

Android没有停在为其他平台体用应用支持:应用的执行依托于顶层JAVA中间件,那个中间件运行在嵌入式Linux 内核之上。

因此开发人员要把他们的应用部署到Android必需利用其自概念的用户界面环境。

另外,android系统应用限制各应用彼此挪用API协作,而且对方为自己的用户应用进行身份验证。

尽管这些应用有必然的平安特性,咱们一些有体会的开发人员开发android应用人士透露,设计平安应用程序并非老是直线前进的。

Android利用一个简单的许可标签分派模式限制访问的资源,但其他应用程序的缘故必要性和便利,其设计师们增加了困惑对那个系统。

本文试图对Android 的平安的复杂性进行讲解,并注意一些可能的进展缺点和应用程序的平安。

咱们通过尝试得出一些体会教训,希望对以后的平安有效。

Android应用程序框架对开发者来讲是一个强制架构。

它没有一个main()函数功能或单一入口点执行,相反,开发人员必需在设计方面的应用组件。

咱们开发的应用对android的sdk的帮忙的API
Android系统概念了4种组件类型。

Activity 组件概念应用程序的用户界面。

通常,应用程序开发者概念每一个活动“画面。

”Activity能够自己开始,也可能通过传递和返回值。

在一时刻只有一个键盘的系统Activity能够进行处置,在那个时候所有其他的Activity都会被暂停。

Service组件执行后台处置。

当一个活动需要进行一些操作,在用户界面消失以后(如下载一个文件或播放音乐),它通常采取此种动作特殊设计的效劳。

开发人员还能够在系统启动利用特殊的守护进程,Service通常概念一个远程进程挪用(RPC),其他系统组件能够用来传送接口命令和检索数据,和注册一个回调函数。

ContentProvider组件存储和共享数据用关系数据库接口。

每一个Content 供给者都有一个关联的“权限”来形容它的内容包括。

其他组件利历时作为一个handle执行SQL查询(如SELECT,INSERT或DELETE内容。

尽管Content供给者通常存储把数值放在数据库记录中,数据检索是实现特殊的例子,文件也同时通过内容提供商共享接口。

Broadcast receiver该组件作为为从邮件信箱发送信息给他应用程序。

通常,广播消息的应用程序代码隐含的目的地。

因此,广播接收器定阅这些目的地接收发送给它的消息。

应用程序代码也能够解决明确广播接收机包括命名空间分派。

Component Interaction该组件交互的要紧机制是一个intent ,这是一个简单的消息对象,其中包括一个目的地组件的地址和数据。

Android的API概念了他的方式中传入intent ,并利用该信息来启动一个activity例如开始一个activity(startActivity(intent)),启动效劳(startService(intent))和广播信息(sendBroadcast(intent))。

Android框架来通知这些方式的挪用开始执行在目标应用程序代码。

那个进程中内部组件通信称为一个动作。

简单地说, Intent对象概念的“Intent”以执行“action”。

Android的一个最壮
大的特点是许诺的多种intent寻址机制。

开发人员能够解决一个目标组件利用其应用的空间,他们也能够指定一个隐含的名称。

在后一种情形下,系统决定了一个action的最正确组件,通过考虑安装的应用程序和用户的选择。

那个隐含的名字被称为动作字符串因为他特殊的类型的请求动作。

例如一个view动作字符串,在一个intent中和数据域指向一个图像文件,系统将会直接指首选图像阅读器。

开发者也能利用动作字符串进行大量广播发送和接收。

在接收端的接收者,开发者利用一intent 过滤器来定制特殊的动作字符串。

Android系包括附加目标的决议规那么,但可选的数据操作字符串类型是最多见的。

Android应用程序利用Java编程语言开发。

apt工具吧编译后的Java代码连同应用程序所需的其他数据和资源文件一路打包到一个Android包文件中,那个文件利用.apk作为扩展名。

此文件是分发并安装应用程序到移动设备的载体;是用户下载到他们的设备的文件。

单一.apk文件中的所有代码被以为是一个应用程序。

从多个角度来看,每一个Android应用程序都存在于它自己的世界当中:
1.默许情形下,每一个应用程序均运行于它自己的Linux进程中。

当应用程序中的任何代码需要被执行时,Android启动此进程,而当再也不需要此进程而且其它应用程序又请求系统资源时,那么关闭那个进程。

2.每一个进程都有其特有的虚拟机(VM),因此应用程序代码与其它应用程序代码是隔离运行的。

3.默许情形下,每一个应用程序均被给予一个唯一的Linux用户ID,并加以权限设置,使得应用程序的文件仅对此用户及此应用程序可见—尽管也有其它的方式使得这些文件一样能为其他应用程序访问。

1.应用程序组件
Android的一个核心特性确实是一个应用程序能够利用其它应用程序的元素(若是那个应用程序许诺的话)。

例如,若是你的应用程序需要显示一个图片卷动列表,而另一个应用程序已经开发了一个合用的而又许诺别的应用程序利用的话,你能够直接挪用那个卷动列表来完成工作,而不用自己再开发一个。

你的应用程序并无吸纳或链接其它应用程序的代码。

它只是在有需求的时候启动了其
它应用程序的那个功能部份。

为达到那个目的,系统必需能够在一个应用程序的任何一部份被需要时启动一个此应用程序的进程,并将那个部份的Java对象实例化。

因此,不像其它大多数系统上的应用程序,Android应用程序并无为应用程序提供一个单独的入口点(比如说,没有main()函数),而是为系统提供了能够实例化和运行所需要的必备组件。

一共四种组件类型:
(1)Activity
Activity是为用户操作而展现的可视化用户界面。

例如,一个activity能够展现一个菜单项列表供用户选择,接着显示一些包括说明文字的照片。

一个短消息应用程序能够包括一个用于显示要发送消息到的联系人列表的activity,一个给选定的联系人写短信的activity和翻阅以前的短信或改变设置的其他activity。

尽管它们一路组成了一个内聚的用户界面,但其中每一个activity 都不与其它的维持独立。

每一个都实现为以Activity类为基类的子类。

一个应用程序能够只有一个activity,或,如适才提到的短信应用程序那样,包括很多个。

每一个activity的作用,和有多少个activity,固然是取决于应用程序及其设计的。

一样情形下,总有一个应用程序被标记为用户在应用程序启动的时候第一个看到的。

从一个activity转向另一个activity靠的是用当前的activity启动下一个。

每一个activity都被给予一个默许的窗口以进行绘制。

一样情形下,那个窗口是满屏的,但它也能够是一个小的位于其它窗口之上的浮动窗口。

一个activity也能够利用附加窗口—例如,一个在activity运行进程中弹出的供用户响应的对话框,或是一个当用户选择了屏幕上特定项目后显示的必要信息的窗口。

窗口显示的可视内容是由一系列层次化view组成的,这些view均继承自View基类。

每一个view均操纵着窗口中一块特定的矩形区域中进行绘制,并对用户直达其区域的操作做出响应。

因此,view是activity与用户进行交互的界面。

例如,view能够显示一个小图片,并在用户指定它的时候产生动作。

Android 有一些预置的view供开发者利用—包括按钮、文本域、转动条、菜单项、复选框等等。

view层次结构是由Activity.setContentView()方式放入activity的窗口当中的。

content view是位于层次结构根位置的View对象。

(参见独立的用户界面文档以读取关于view及层次结构的更多信息。


2.Service
Service没有可视化的用户界面,而是在一段时刻内在后台运行,例如,一个service能够在用户做其它情形的时候在后台播放背景音乐、从网络上获取数据或计算一些东西并提供给需要那个运算结果的activity利用。

每一个service 都继承自Service基类。

一个媒体播放器播放列表中的曲目是一个不错的例子。

播放器应用程序可能有一个或多个activity来给用户选择歌曲并进行播放。

但是,音乐播放那个任务本身应该由任何activity来处置,因为用户期望即便在他们离开播放器应用程序而开始做别的情形时,音乐仍在继续播放。

为达到那个目的,媒体播放器activity能够启动一个运行于后台的service。

系统将在那个activity再也不显示于屏幕后,仍维持音乐播放service的运行。

连接至(绑定到)一个正在运行的service(若是service没有运行,那么启动之)是可能的。

连接以后,你能够通过那个service暴露出来的接口不service进行通信。

关于音乐service来讲,那个接口能够许诺用户暂停、回退、停止和从头开始播放。

犹如activity和其它组件一样,service运行于应用程序进程的主线程内。

因此它可不能对其他组价或用户界面有任何妨碍,它们一样会派生一个新线程来执行一些时刻消耗型任务(比如音乐回放)。

参见稍后的进程和线程。

(1)Broadcast receiver
Broadcast receiver是一个与注于接收广播通知信息,并做出相应处置的组件。

许多广播是由系统代码产生的—例如,通知时区改变、电池电量低、拍照了一张照片或用户改变了语言选项。

应用程序也能够发起广播—例如,通知其它应用程序一些数据已经下载到设备上处于可用状态。

一个应用程序能够拥有任意数量的broadcast receiver,以对所有它以为重要的通知信息予以响应。

所有的receiver均继承自Broadcast Receiver基类。

Broadcast receiver没有效户界面。

但是,它们能够启动一个activity来。

相关文档
最新文档