Service

1. Service被设计成长期运行的组件,相反生命周期短并且随时被停止运行的组件包括Activities, content providers, 和 intent receivers。

      Activities, content providers, and intent receivers are all short-lived and can be shut down at any time. Services, on the other hand, are designed to keep running, if needed, independent of any activity.

 

2.应用的场合

     You might use a service for checking for updates to an RSS feed, or to play back music even if the controlling activity is no longer operating.playing music even if the "player" activity gets garbage-collected, polling the Internet for RSS/Atom feed updates, and maintaining an online chat connection even if the chat client loses focus due to an incoming phone call.

 

3.IPC inter-process communication

 

4.注意的问题

Service可能会长期占用系统资源,会引发电池不足的现象。

 

5.创建Service

(1)定义子类继承Service

(2)重写onCreate()/onStart()/onDestroy()...

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值