I have a Service downloading data every second from a web server (This Service is launched from my main Activity). In my app there are other Activitys each of them needs to refresh their UI according to the data downloaded by the Service.
My idea is to give to each of my Activitys an AsyncTask which will retrieve a small amoumt of data from the Service every second. Then the AsyncTask will tell to the UI to update.
Until yesterday I was all doing through AsyncTask, but I read this morning on stackoverflow that retrieving data and giving it to several Activitys is more a Service job than an AsyncTask one.
So I came up with this (not-so-good-even-a-bit-crapy) solution because I can’t find how to notify my Activitys when the data is retrieved by the Service.
I read about broadcast receiver, listener, intent… but can’t figure out how I can make my Activity‘s “subscribe” to this one service periodically.
Thanks for your help.
PS : is it ridiculous to code sample each of my keywords in my writing like that 🙂 ?
PS2 : use case of my app is retrieving temperature, pressure etc… from web services and monitoring each of these quantities in a different Activity (I can’t monitor them all in the same Activity).
Data can be refreshed over activity from service thru Handler.
Follow this link for handler.