1new Timer().scheduleAtFixedRate(new TimerTask(){
2 @Override
3 public void run(){
4 Log.i("tag", "A Kiss every 5 seconds");
5 }
6},0,5000);
7// SETINTERVAL
8
1// Param is optional, to run task on UI thread.
2Handler handler = new Handler(Looper.getMainLooper());
3Runnable runnable = new Runnable() {
4 @Override
5 public void run() {
6 // Do the task...
7 handler.postDelayed(this, milliseconds) // Optional, to repeat the task.
8 }
9};
10handler.postDelayed(runnable, milliseconds);
11
12// Stop a repeating task like this.
13handler.removeCallbacks(runnable);