Frage

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 in the constructor of the IntentService object?

War es hilfreich?

Lösung

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).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top