Service.onDestroy() is called directly after creation, anyway the Service does its work

前端 未结 1 1583
轻奢々
轻奢々 2020-12-20 12:31

I built a Service and it didn\'t work as expected, so I debugged it. During debugging, I saw that the service\'s onDestroy() method is called directly after returning from o

相关标签:
1条回答
  • 2020-12-20 13:27

    If you are subclassing IntentService you should be using onHandleIntent(Intent intent) for the lifecycle of your service. Your service might be moving to onDestroy quickly becuase you do not have code inside of onHandleIntent. Although without your code I cannot say for sure.

    Also it might aways move to onDestroy quickly because IntentService is auto threaded for you and might just launch the worker thread which calls onHandleIntent and move to onDestroy.

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