How do I keep the Thread of an IntentService alive?

自闭症网瘾萝莉.ら 提交于 2019-11-29 11:05:58
CommonsWare

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.

Consider using a remote service. It worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!