开发者

How to understand android Service?

I am newbe of android,and I am confused about android service,according my understanding,UI-related code run in a开发者_StackOverflowctivity,and background work run in my own thread,so,what's usage of service? It seems I can use activity and thread to do anything.


Background work can and should be run in a thread. However, if that work is not part of a service, the OS may stop that thread without warning if none of the app's activities are visible.

For example, if you write an MP3 player app, you will probably not want the music to stop if the user returns to the home screen. So you make a service that actually plays the music, and then the OS will try to avoid killing your app's process if the service is running.

Services can also be used to provide functionality for other applications. In that case, the app's process will be started on demand when some other app wishes to utilize the service, and may be stopped by the OS once the other apps are finished with the service.

See the Service Documentation for more details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜