Android的重复性任务 [英] Android Repetitive Task
本文介绍了Android的重复性任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在一个活动,我需要调用Web服务,每30秒左右,并利用这些数据来更新UI。
In an Activity, I need to call a web service every 30 seconds or so, and use the data to update the UI.
有没有关于如何计划重复任务建议的方法?
Is there a recommended approach on how to schedule a repetitive task?
感谢
推荐答案
如果这是在运行的活动,你可以使用的 定时器
/的 的TimerTask
和的 处理程序
,或者你可以使用<一个href="http://developer.android.com/reference/android/view/View.html#postDelayed%28java.lang.Runnable,%20long%29"相对=nofollow> postDelayed()
和的 的AsyncTask
。
If this is in a running activity, you could use Timer
/TimerTask
and a Handler
, or you could use postDelayed()
and an AsyncTask
.
这篇关于Android的重复性任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文