How do I keep the Thread of an IntentService alive?

前端 未结 2 1105
独厮守ぢ
独厮守ぢ 2020-12-19 10:53

I\'m writing a test application which keeps track of the users location. The idea is that i can start a service which then registers for location updates. For now I\'m using

相关标签:
2条回答
  • 2020-12-19 11:32

    Consider using a remote service. It worked for me.

    0 讨论(0)
  • 2020-12-19 11:43

    How do I keep the Thread of an IntentService alive?

    You don't. You do not use IntentService in a scenario like this.

    I need some mechanism which keeps the thread alive (because else the listener is not reachable anymore for status updates) and doesnt waste cpu time (I think busy looping is not the preferred way)

    No, in this case a Service is fine, because you control when the service is going away, you control the lifetime of any threads you create, etc. IntentService is unsuitable for your intended purpose, because it controls when the service is going away and it controls the lifetime of the threads.

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