`

Android Service

 
阅读更多

在AndroidManifest.XML中注册service:

创建一个Service:


启动Service:Context.startService()

停止Service:Context.stopService()

Service自己停止:Service.stopSelf()

下列方法会一次调用KitchenTimerService的:onCreate(),onStart(),onBind(),onUnbind(),onRebind()方法:

如果不申明ServiceConnection程序,ServiceConnection接口里的onServiceDisconnected method只会在Service被停止或者被系统杀死以后调用。
也就是说你执行unbindService 只是告诉系统你已经和这个服务没有关系了。系统在内存不足的时候可以优先杀死这个服务而已。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics