Can I call stopSelf() in Service.onStartCommand?

后端 未结 1 707
有刺的猬
有刺的猬 2020-12-29 19:14

There are some conditions where my service could be attempted to be started when it should not be. In cases like this is it bad form to call stopSelf() while in

相关标签:
1条回答
  • 2020-12-29 20:06

    is it bad form to call stopSelf() while inside a onStartCommand() method?

    Off the top of my head, I can't think of why that would be a problem.

    stopSelf(), like a lot of stuff in Android, has no immediate effect. It puts a message on the message queue processed by the main application thread. The actual work of stopping the service will not even begin until sometime after onStartCommand() has returned.

    0 讨论(0)
提交回复
热议问题