I have an application that needs updating constantly. I would like to create a job (Service, thread …?) that execute the polling over all the activities. I need to update some data even if i’m not on the activity that needs to.
I would not create a service because actually I don’t need to update tha application along it is closed.
What do you suggest?
Thanks
a.
I think you are confusing an
Activitywith the data that it presents to the user. You do not mess with other activities that are not currently on screen.If I understand correctly, you want to update some data that is shared among your activities whenever any activity is currently visible.
You could create a
Servicewhich in turn uses a separate thread to do its polling. Then in each of your activities that you want the polling to be run you callstartServicein theonResumemethod of the activity andstopServicein theonPausemethod of the activity.Also make sure you use
returnSTART_STICKYat the end of your service’sonStartCommandmethod.