开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜