IntentService life cycle
I have an IntentService that handles asynchronous calls to a Drupal Services module. Currently, I have my DrupalXmlRpcService object being initialized every time in onHandleIntent because I was under the impression that the service would be killed after the thread is finished. Should this object be initialized 开发者_Go百科in the constructor of the IntentService object?
If your DrupalXmlRpcService
object is expensive to create and you use it often, consider saving a reference in the global Application
object, or possibly making it a singleton (make sure it's thread-safe). As for your question, if you send multiple Intents to the same service, handleIntent()
might be called multiple times, so you might want to init in the constructor (but if it takes too long that might block the main thread).
精彩评论