UMAR-MOBITSOLUTIONS
UMAR-MOBITSOLUTIONS

Reputation: 77984

calling a function in android after intervals?

I would like to call a function ABC() every 10 seconds, again 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?

Upvotes: 3

Views: 5486

Answers (1)

Denis Palnitsky
Denis Palnitsky

Reputation: 18387

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

Upvotes: 7

Related Questions