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