Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Background Service vs AlarmManager

Can someone give a little bit briefing or perhaps more elaborate details on differences Android background service with Alarm Manager?

How they differ? And in which situation I should use each?

I am developing an application that need to download data from Web Service at periodic time. The application has few modules and each modules has different interval time period to download / sync the data to Web Service.

Let say + Module A need to sync in every 15 mins + Module B need to sync in every 1 hour + Module C need to sync in every day + Module D need to sync weekly + Module E need to sync monthly

Which approach is better? And why?

Regards

like image 679
stuckedoverflow Avatar asked Oct 19 '11 07:10

stuckedoverflow


1 Answers

AlarmManager schedule the intents. Your service can crash and be removed if memory is not available. But with AlarmManager you can invoke your specific service at a scheduled time. In your context, AlarmManager is a better option than a running service.

Hope it will help you.

like image 174
Cool Java guy מוחמד Avatar answered Sep 27 '22 16:09

Cool Java guy מוחמד