有人可以提供一些有关差异的简短介绍或更详细的细节吗?
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?
我正在开发一个需要定期从Web Service下载数据的应用程序。该应用程序只有几个模块,每个模块都有不同的间隔时间来下载数据/将数据同步到Web服务。
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.
让我们说 +模块A需要同步每15分钟 +模块B需要每1小时同步 +模块C需要每天同步 +模块D需要每周同步 +模块E需要每月同步
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?
致谢
推荐答案AlarmManager计划意图。如果没有可用的内存,您的服务可能会崩溃并被删除。但是,使用AlarmManager,您可以在计划的时间调用特定的服务。在您的上下文中,AlarmManager比正在运行的服务更好。
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.
更多推荐
Android后台服务与AlarmManager
发布评论