如何定期调用asyncTasks

我有两个AsyncTasks在做网络操作。 我想定期打电话给他们(比如一分钟之后)。 我怎么做? 我不认为我可以在UI线程上做到这一点。 我需要创建一个新线程吗? 没有AlarmManager / Service可以实现这个吗?

基本上我想在一分钟之后定期检出这两个陈述。

new UploadAsyncTask().execute(); new DownloadAsyncTask().execute(); 

谢谢

只需使用计时器。

 final Handler handler = new Handler(); Timer timer = new Timer(); TimerTask task = new TimerTask() { @Override public void run() { handler.post(new Runnable() { public void run() { new UploadAsyncTask().execute(); new DownloadAsyncTask().execute(); } }); } }; timer.schedule(task, 0, 1000); //it executes this every 1000ms