Android 开发文档 程序基础 ——Services组件
2010-06-19 10:44
387 查看
service没有可视化用户界面,运行在后台,在不确定的时间。service都是extends于Service基类。
也可以链接或者绑定到一个运行中的service。连接时可以通过一个可视化界面来交互。
像其他组件一样,service是运行程序进程的主线程中。所以service不会block其他组件或者用户界面,而是为time-
consuming tasks?耗时的任务产生另一个线程。
转自我的android博客
原文
Services
A
service
doesn’t have a visua
l user
interface, but rather runs in the background for an indefinite period
of time.Each service extends the Service
base class.
A prime example is a media player playing 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 not be handled by an activity because
users will expect the music to keep playing even after they leave the
player and begin something different. 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 Threads,
later.
也可以链接或者绑定到一个运行中的service。连接时可以通过一个可视化界面来交互。
像其他组件一样,service是运行程序进程的主线程中。所以service不会block其他组件或者用户界面,而是为time-
consuming tasks?耗时的任务产生另一个线程。
转自我的android博客
原文
Services
A
service
doesn’t have a visua
l user
interface, but rather runs in the background for an indefinite period
of time.Each service extends the Service
base class.
A prime example is a media player playing 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 not be handled by an activity because
users will expect the music to keep playing even after they leave the
player and begin something different. 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 Threads,
later.
相关文章推荐
- Android 开发文档 程序基础 ——activity组件
- Android 开发文档 程序基础 ——Content providers组件
- Android 开发文档 程序基础——The manifest file
- Android 开发文档 程序基础——Intent filters
- Android 开发文档 之程序基础Application Fundamentals
- Android 开发文档 程序基础——Activities and Tasks
- Android 开发文档 程序基础 ——Broadcast receivers组件
- Android 开发文档 程序基础——Affinities and new tasks
- Android 开发文档 程序基础——Activating components: intents
- Android 开发文档 程序基础——Shutting down components
- Android开发之道(4)程序框架基础
- Android开发之道(4)程序框架基础
- Android开发之旅5:应用程序基础及组件
- android官方文档---应用程序基础---服务的理解(app Component---services)
- Android 程序开发——百度地图的使用(一) 基础配置
- Android开发文档之App组件基本原理
- Android官方开发文档Training系列课程中文版:构建第一款安卓应用之程序运行
- Android开发之旅:应用程序基础及组件
- 24、Android开发基础之组件之间的数据传输(视频+文章)
- React Native 开发基础组件 触摸组件 类似于android原生 button