美文网首页
bindService 和startService 终止方法

bindService 和startService 终止方法

作者: YourChoice | 来源:发表于2020-09-28 16:17 被阅读0次

一、bindService 解除绑定方法:

(1) unbindService 解除绑定

(2)绑定的Context 被 finish 的时候绑定会自动解除

二、startService 的终止方法:

(3)调用stopService

(4)自身的stopSelf方法(当然如果系统资源不足,android系统也可能结束服务)

三、同时使用 startService 与 bindService Service 的终止方法:

需要unbindService与stopService同时调用,才能终止 Service。不管 startService 与 bindService 的调用顺序。也即是说上面的方法startservice和binderservice的终止方法中必须出现一个,也就是(1)(3),(1)(4),(2)(3),(2)(4)。

相关文章

网友评论

      本文标题:bindService 和startService 终止方法

      本文链接:https://www.haomeiwen.com/subject/yufbektx.html