我正在查看文档,但它并没有真正解释这个问题。我确实找到了这个:
The service will at this point continue running until Context.stopService()
or stopSelf() is called.
这告诉我服务将继续运行,但是假设当方向发生变化时,Activity / Fragment不会自动停止它已启动的服务。我也发现了这个:
Using startService() overrides the default service lifetime that is managed by
bindService(Intent, ServiceConnection, int): it requires the service to remain
running until stopService(Intent) is called, regardless of whether any
clients are connected to it.
在明确调用stopService
之前,我能否假设服务实际上不会停止?
答案 0 :(得分:1)
是的。您必须使用stopService()方法停止它,或者您可以使用stopSelf()在不再需要服务时停止。它将自动停止服务。
答案 1 :(得分:1)
标题,答案是否。
当呼叫活动/片段改变方向时,服务不会停止。它继续运行,除非或直到它被明确停止
对于描述,答案是肯定的。
您肯定需要调用stopService()
或stopSelf()
函数来停止服务。