问题描述
我试图做一个Android应用程序每15分钟获取索姆样的RSS其触点的网络服务器。我知道如何获取RSS,但我的问题是我如何使应用程序定期与联系网络服务器。
I'm trying to make an Android app which contacts a webserver every 15 minutes to retrieve som kind of RSS. I know how to retrieve the RSS, but my problem is how I make the app contact the webserver periodically.
我读过有关的服务,处理程序,定时器和可运行,但我不知道其中哪些我应该使用,而我应该怎么使用它们。
I've read about services, handlers, timers and runnables but I don't know which of them I should use, and how I should use them.
先谢谢了。
推荐答案
这需要执行轮询操作独立于任何活动的应使用 AlarmManager
的调度大多数事情一样,用自己的 IntentService
实际投票逻辑的实现。如果你打算为设备唤醒退出睡眠模式做的工作,你需要有一个 _WAKEUP
报警 AlarmManager
,也许我的。
Most things that need to perform a polling operation independent of any activities should use AlarmManager
for the scheduling, with your own IntentService
for the implementation of the actual polling logic. If you intend for the device to wake up out of sleep mode to do the work, you will need a _WAKEUP
alarm with the AlarmManager
and perhaps my WakefulIntentService
.
这篇关于服务,处理程序,定时器,可运行 - 它使用和如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!