最好的办法定期执行AsyncTasks Android中 [英] Best way to periodically executing AsyncTasks in Android

查看:123
本文介绍了最好的办法定期执行AsyncTasks Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am getting data from the server using AsyncTask. I need to update the data periodically.

最新最好的方式做到这一点?

Whats the best way to do it?

推荐答案

您可以使用Timer类使用的TimerTask,而不是AsyncTask的调度周期性任务

You could use Timer class to schedule periodic task using TimerTask instead of AsyncTask

请参阅:

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

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

和更新你的UI,你应该遵循这个好教程:

And to update your UI you should follow this good tutorial :

http://android-developers.blogspot.com/十一分之二千○七/缝合为time.html

这篇关于最好的办法定期执行AsyncTasks Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆