您的位置:首页 > 其它

四大组件之Service

2015-11-23 14:30 120 查看
Service
 is
an application component that can perform long-running operations in the background and does not provide a user interface. Another application component can start a service and it will continue to run in the background even if the user switches to another
application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service might handle network transactions, play music, perform file I/O, or interact with a content provider,
all from the background.

服务是可以在后台执行长时间运行操作,并且不提供用户界面的应用组件。另一个应用程序组件可以启动服务,它将继续存在即使用户切换到另一个应用程序在后台运行。此外,一个组件可以绑定到一个服务来与它交流,甚至进行进程间通信(IPC)。例如,服务可能处理网络交易,播放音乐,执行文件I / O,或与Content Provider进行交互,所有都是从后台运行

A service can essentially take two forms:

服务基本上可以采取两种形式:

StartedA service is "started" when an application component (such as an activity) starts it by calling
startService()
.
Once started, a service can run in the background indefinitely, even if the component that started it is destroyed. Usually, a started service performs a single operation and does not return a result to the caller. For example, it might download or upload
a file over the network. When the operation is done, the service should stop itself.
Started

       服务的“启动”当应用程序组件(如Activity)通过调用startService启动它,一旦开始,一个服务可以在后台运行下去,即使启动它的组件被破坏。一般,服务执行单次操作,其结果不返回给调用者。例如,它可以下载或上传文件在网络上。当操作完成时,服务应停止本身。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: