Java tutorial
//package com.java2s; import java.util.Timer; import java.util.TimerTask; import android.os.Handler; public class Main { public static Timer setInterval(final Runnable runnable, int delayMillis, int period) { final Handler handler = new Handler(); Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { handler.post(runnable); } }, delayMillis, period); return timer; } }