> I have a ListView containing a list of objects with TextViews. I want > to periodically update these TextViews on a periodic basis in the > background (I make an http post request to a server to receive the > updated text, and then insert it into the text view). I don't want > the periodic updating of these views to interfere with the user > experience. > > There are several ways I could think about doing this... either > through using a Service which I call periodically, a Service which > periodically sends updates (though I dunno if a Service can update an > Activity's list view), or spinning off a separate Thread from the > original Activity. > > Does anyone have any suggestions which option would be optimal, and > why?
If you want to collect the data via HTTP regardless of whether the activity is visible, hidden, or killed off (e.g., due to low RAM), then the Service is the way to go. The activity could either poll the service, or the Service could raise an Intent that the activity receives to trigger the screen update. In the latter case, though, be sure to use a Handler so the screen update happens on the UI thread -- Android, like Swing, requires all UI updates be performed on the magic UI thread. If you want the data to be potentially available to other applications, besides your own (e.g., your Service is fetching RSS/Atom feeds), then a Service is the way to go. If everything is truly local to the activity, then a background thread and Handler could work. -- Mark Murphy (a Commons Guy) http://commonsware.com The Busy Coder's Guide to Android Development -- coming in June 2008! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] Announcing the new M5 SDK! http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

