Please pardon the newbie nature of this question. I am a 30 year programmer, but an Android beginner.
I am writing an app that requires me to poll a server over the network (I hate polling, but it seems the best idea in this instance). There are two polling loops: one polls every 30 minutes, and one polls every one minute. Very little data is exchanged, so you see that the polling isn't terribly intensive.
From my reading, it at first seemed like I needed a Service. However, when I read about Services they were clear that I would need to use a thread in the service so I don't block the UI. But if I am using a thread, why do I need a Service? This activity is not shared - no other app would access my Service. Why don't I just use two Timers (one for each polling loop) in the main program?
Is the advantage of the service that the polling loop would continue to run even if the application is terminated? So, if the fast loop is checking for notifications then I'd want that to run in a service, but if the slow loop is only applicable while the UI is running then I could do the slow loop as a thread in the app? Given this scenario, could the Service poll start up my app under certain circumstances - or at least turn on a 'gmail'-like icon at the top of the screen?
Thanks in advance for your input.
I am writing an app that requires me to poll a server over the network (I hate polling, but it seems the best idea in this instance). There are two polling loops: one polls every 30 minutes, and one polls every one minute. Very little data is exchanged, so you see that the polling isn't terribly intensive.
From my reading, it at first seemed like I needed a Service. However, when I read about Services they were clear that I would need to use a thread in the service so I don't block the UI. But if I am using a thread, why do I need a Service? This activity is not shared - no other app would access my Service. Why don't I just use two Timers (one for each polling loop) in the main program?
Is the advantage of the service that the polling loop would continue to run even if the application is terminated? So, if the fast loop is checking for notifications then I'd want that to run in a service, but if the slow loop is only applicable while the UI is running then I could do the slow loop as a thread in the app? Given this scenario, could the Service poll start up my app under certain circumstances - or at least turn on a 'gmail'-like icon at the top of the screen?
Thanks in advance for your input.