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

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?

Thanks,

James

--~--~---------~--~----~------------~-------~--~----~



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)
 http://commonsware.com 
The Busy Coder's Guide to Android Development -- coming in June 2008!


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Hello, Please help me get back into the developer group discussion board

Hi,

Thanks  for your help.

its been 5 or 6 weeks since I've been able to work on my android project but 
now I can't log back into the group.
I've reset the password but that hasn't worked either.

Thanks again,

Zack.

[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~

2. Emulator crashes X on Ubuntu 8.4

I'm running 64-bit Ubuntu 8.4
    (2.6.24-19-generic #1 SMP Wed Aug 20 17:53:40 UTC 2008 x86_64 GNU/Linux)
I have installed Sun's 64-bit JDK, Eclipse 64-bit 3.4, and Android SDK 
1.0 r1.

The hardware is an an Intel DG35EC motherboard with onboard Intel graphics
media accelerator X3500 (this is the xserver-xorg-video-i810 & 
xserver-xorg-video-intel drivers)
and a quad core processor.

The problem is that when I attempt to run the emulator, either from the 
command line
or from Eclipse, it crashes my X server.

Anyone have a similar experience?  Know of any special config params 
that will solve my problem?

Any of the Android team know of anything the same or similar that 
happened in
testing?

Thanks in advance.

/J




--~--~---------~--~----~------------~-------~--~----~

3. View after ListView does not show up

4. Lunar Lander IllegalThreadStateException

5. how to download and install applications on android phone

6. custom UI

7. ActiveSync with Outlook, Exchange and Business Users