在Android中定期执行AsyncTasks的最佳方法


问题内容

我正在使用从服务器获取数据AsyncTask。我需要定期更新数据。

最好的方法是什么?


问题答案:

您可以使用Timer类使用TimerTask而不是AsyncTask安排定期任务

见:

http://developer.android.com/reference/java/util/Timer.html

http://developer.android.com/reference/java/util/TimerTask.html

要更新您的用户界面,您应该遵循以下良好教程:

http://android-developers.blogspot.com/2007/11/stitch-in-
time.html