如果我不调用stopService()或stopSelf()方法,服务何时停止

时间:2016-02-19 11:11:11

标签: android android-service

If you start a service by calling startService() then you have to call stopService() or stopSelf() to stop the service.If you want to stop a service after doing some work, you might want to use IntentService instead.

如果我NOT使用IntentService,那么如果我不拨打stopService()stopSelf()方法,服务何时会停止?

1 个答案:

答案 0 :(得分:0)

  

如果我不使用IntentService,那么如果我不调用stopService()或stopSelf()方法,服务何时会停止?

如果您的服务是通过startService()启动的,并且您没有致电stopService()stopSelf(),那么您的服务将被视为“正在运行”,直到您的流程终止为止。作为此项的一部分,您可能会或可能不会使用onDestroy()进行调用,具体取决于您对进程的系统RAM的需求程度。

如果从onStartCommand()返回START_STICKYSTART_REDELIVER_INTENT,那么您的进程和服务应该在不久的将来某个时间自动重启需要许可。

相关问题