I have two AsyncTasks doing network operations. I want to call them periodically (like after one min.). How do I do that? I dont think I can do it on the UI thread. Do i nee
Just use a timer.
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