timertask

How to execute Async task repeatedly after fixed time intervals

女生的网名这么多〃 提交于 2019-11-26 01:46:43
问题 How to make Async task execute repeatedly after some time interval just like Timer...Actually I am developing an application that will download automatically all the latest unread greeting from the server and for that purpose I have to check for updates from server after some fixed time intervals....I know that can be easily done through timer but I want to use async task which I think is more efficient for android applications. 回答1: public void callAsynchronousTask() { final Handler handler

Timertask or Handler

非 Y 不嫁゛ 提交于 2019-11-26 01:07:43
问题 Let\'s say that I want to perform some action every 10 seconds and it doesn\'t necessarily need to update the view. The question is: is it better (I mean more efficient and effective) to use timer with timertask like here: final Handler handler = new Handler(); TimerTask timertask = new TimerTask() { @Override public void run() { handler.post(new Runnable() { public void run() { <some task> } }); } }; timer = new Timer(); timer.schedule(timertask, 0, 15000); } or just a handler with