Sync between local service with a thread and an activity
Posted
by Henrik
on Stack Overflow
See other posts from Stack Overflow
or by Henrik
Published on 2010-06-01T07:05:15Z
Indexed on
2010/06/01
7:53 UTC
Read the original article
Hit count: 210
Hello all,
I'm trying to think of a way on how to sync in between a local service and the main activity.
The local service has,
- A thread with a socket connection that could receive data at any time.
- A list/array with data.
- At any time the socket could receive data and add it to the list.
The activity needs to display this data. So when the activity starts up it needs to attach or start the local service and fetch the list. It also needs to be notified if the list is updated.
I think I would need to sync my list somehow so the local service does not add a new entry to it while the activity fetches the list when connecting to the service.
Any ideas?
Thanks.
© Stack Overflow or respective owner