periodic updates of ListView

by kingkung » Tue, 13 May 2008 16:41:36 GMT

Sponsored Links
 Hey all,

I was just hoping to get some suggestions on the best way to implement

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

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




periodic updates of ListView

by Mark Murphy » Tue, 13 May 2008 17:40:25 GMT

 > I have a ListView containing a list of objects with TextViews.  I want

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) 
The Busy Coder's Guide to Android Development -- coming in June 2008!


Sponsored Links

Other Threads

1. No one ever answer my posts !!!!

Rotem Or


2. Porting RDP (Remote Desktop Protocol) to Android -- questions

Attempting to port RDP to Android ... saw someone had started this,
Desktoid/Connectoid, but that effort seems to have stopped .. and I
need this function immediately.   I have initial screen image of the
Desktop displayed (with some local Android GUI expert's help) on the
Android as a Bitmap.

There are several calls that RDP does which I can not find equivalents
in the Android GUI.   Those in the subject and others:

drawGlyph, setClip, Cursor,  IndexColorModel, etc.

Just to get the initial image was not without considerable effort ...
"little" things like which Bitmap.Config was used was key ... seems it
requires Bitmap.Config.RGB_565  (others did not work, and without
understanding as to why ?).

Willing to partner with any experts out there to get this completed.
Think it a very useful utility.

Of course, we need to have real ENTERPRISE WPA (even iPhone has this
out of the box) to really make this complete (instead of doing it on
emulator only :-)

Thanks for any assistance anyone can provide.
Kirk Beaty


3. Google map does not work.

4. Retrieving the default email from the email client provided by Android

5. Spinner to play sound.

6. Metal replacement battery cover?

7. Build apk from command line