I need to fetch news/event updates from the server at regular intervals like for every 20mins in my Android App. AFAIK Intent Service and Broadcast Receiver combination will be better than using Service As I am not going to communicate with the running Service. In order to fetch events at regular intervals I know 2 options
1) Using Timer Task ScheduleAtFixedRate, I am going to start IntentService, which will fetch events once & broadcast if any updates and destroy itself. After Given Interval, IntentService will be again fired by TimerTask
2) Simply starting Intent Service at the start of app and within Intent Service onHandleIntent method Starting a TimerTask ScheduleAtFixedRate. If this is preferred way, How and when I cancel Timer Task and When the Intent Service is going to get Destroyed.
or I have to use Alarm Manager. Note I need these updates as long as I am using the App, also I need updates for every 20 to 30 mins not for every 1 or 3 mins.
Any body please suggest me, Thanks in Advance.
Go for AlarmManager. I have tried TimerTask before, it does not work properly in some devices and get killed after some time.