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. Android on Eucalyptus

Hi all,
I'm working for my thesis on Eucalyptus. I setted it up and now I want
to run Android platform on it. There is a way to get a kernel image
and eventually also a ram disk? I dispose of liveandroidv0.3.iso
and in Eucalyptus I use kvm as hypervisor.
Anyone can say something to help me?

-- 

2. Where dialog is building

Hi,
When we going for ring tone settings
ie Home->Settings->Sound&DisplaySettings/Phone Ringtone
it is displaying the
ring tones which are added from media player.
If we want to change we can select from the list and press ok.
I want to know the source code of it how it is collecting the data of
ringtones and added to display dialog.
I went to the following file in the google android source code
packages/apps/Settings/src/com/android/settings/SoundAndDisplaySettings.java
But i didn't find how that dialog is building
Any help please,

-- 

3. Service stops works after 30 minutes when Android is turned off (trickles every 30 minutes for 5 minutes)

4. Can I create Tabs from Activity

5. adb push hosts file into /system/etc/ - No space left on device error

6. Request to Join This grou

7. download problem