nilMoBile
nilMoBile

Reputation: 2002

Continuously Running Service verses periodically Starting Service in Android

I wish to do data polling(notifications) from service after a particular time interval(might be around 2-5mins). So I have written a service which will fetch data from the server. So what is the best way from performance point of view from below options.

  1. Starting service every time when polling is to be done using Alarm manager
  2. Or Starting service at Boot Completed using Alarm manager and keeping another Alarm Manager inside service which executes a task every particular time interval.

Thanks all..

Upvotes: 0

Views: 606

Answers (1)

Blehi
Blehi

Reputation: 2020

I think the first option is better. Start IntentService with alarm manager. IntentService will receive the Intents, launch a worker thread, and stop the service as appropriate.

See: http://developer.android.com/reference/android/app/IntentService.html

Upvotes: 1

Related Questions