ok I have this application which needs to send periodic updates to a web-service, I have done a fair amount of research and I’ve come up with two service implementation patterns.
-
Implement a service with a thread, the periodic update time may vary therefore, I will put the thread to sleep with the required time-interval, then call the web-service again. I also need to update an activity, therefore will be using a broadcast receiver or a messenger.
-
Use a Service with a schedule timer/alarm manager, wake the system and use intent services coupled with a broadcast receiver.
Which would be the best approach?
I think I would go with the #2 option :
IntentServiceto do the update.BroadcastReceiverwithIntentFilter(s) and start theIntentServicefrom it.AlarmManagertoBroadcastthe registered action at the required time intervals.I prefer this method because :
IntentService