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,
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.
I answered a somewhat similar question here. In this answer is a link to a presentation hold by mark brady on the droidconf in berlin. In his slides he describes a framework that manages this kind of things. He also offers the source for this on github.
He proposes the following solution. Build a controller object that lives in the scope of an custom application class. The controller starts the service or a simple worker thread and notifies the UI if it gets notified by the service that something changed. He advises against the use of AIDL if it is not absolutely necessary.
The android documentation also offers an example on how to start a local process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With