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中的Service组件,它是一种在后台长时间运行且没有用户界面的服务。Service通常用于执行耗时任务,如播放音乐等。即使启动Service的Activity不再可见,Service也会继续运行。此外,还介绍了如何通过绑定Service来进行交互控制。
223

被折叠的 条评论
为什么被折叠?



