Chat app vs REST app - use a thread in an Activity or a thread in a Service?
<p>In Virgil Dobjanschi's talk, "Developing Android REST client applications" (link <a href="http://code.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html#" rel="nofollow">here</a>), he said a few things that took me by surprise. Including:</p>

<ul>
<li><p>Don't run http queries in threads spawned by your activities.  Instead, communicate with a service to do them, and store the information in a ContentProvider.  Use a ContentObserver to be notified of changes.</p></li>
<li><p><em>Always</em> perform long running tasks in a Service, never in your Activity.</p></li>
<li><p>Stop your Service when you're done with it.</p></li>
</ul>

<p>I understand that he was talking about a REST API, but I'm trying to make it fit with some other ideas I've had for apps.   One of APIs I've been using uses long-polling for their chat interface.  There is a loop http queries, most of which will time out. </p>

<p>This means that, as long as the app hasn't been killed by the OS, or the user hasn't specifically turned off the chat feature, I'll never be done with the Service, and it will stay open forever.  This seems less than optimal.  </p>

<p>Long question short:</p>

<p><b>For a chat application that uses long polling to simulate push and immediate response, is it still best practice to use a Service to perform the HTTP queries, and store the information in a ContentProvider?</b></p>
