我使用 Activity 绑定(bind)到服务,然后调用 startService() 来让服务执行任务。
当服务完成任务时,它会调用 stopSelf()
。当然,在我的 Activity 解除绑定(bind)之前,服务不会停止。当 Service 调用 stopSelf()
之后 Activity 再次调用 startService()
时会发生什么。一旦Activity解除绑定(bind),Service会被销毁还是会继续运行?
最佳答案
通过反复试验,该服务似乎仍在继续运行。
Activity 对 startService()
的调用有效地取消了服务之前对 stopSelf()
的调用。
我的实验代码可以在这里找到。 https://gist.github.com/Proper-Job/56d22b36714e3339be05
关于android - 当 Service 在调用 stopSelf() 后收到启动命令时会发生什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25434006/