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

Kun*_*ati 11 java android

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

什么是最好的方法呢?

Mat*_*ieu 5

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

见:

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

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

要更新您的UI,您应该遵循这个好的教程:

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