• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating a listView from a service in android?

 
Abhinav Pathak
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a list View which updates lets say at every 30 seconds during peak hours, I want to update my list view from a Service. Which of the following options are best?

1) Using a Broadcast receiver to update the List.

2) Creating a new Thread in my UI and reading a static variable for any changes , change the static variable from the service.

if there are any other options in your mind please tell.

Thank you
 
David Griffiths
Author
Ranch Hand
Posts: 45
5
Android Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could bind the service in the activity, then use a runnable with a handler to query the service every 10 seconds. The runnable/handler would allow you to update the list without any thread problems. Your service could expose the data via a simple getter.

I'm sure there are several other ways.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic