calling a function in android after intervals?
I would like to call a function ABC()
every 10 seconds, a开发者_高级运维gain and again till I use return statement to quit. But I don't want to use any Java Time
function.
Anyone can guide me how to achieve this?
Use CountDownTimer
CountDownTimer t = new CountDownTimer( Long.MAX_VALUE , 10000) {
// This is called every interval. (Every 10 seconds in this example)
public void onTick(long millisUntilFinished) {
Log.d("test","Timer tick");
}
public void onFinish() {
Log.d("test","Timer last tick");
start();
}
}.start();
精彩评论