Android - Starting a Timer using Handler
private final static int DELAY = 30000; private final Handler handler = new Handler(); private Timer timer;
private void launchTimer() { TimerTask timerTask = new TimerTask() { @Override public void run() { handler.post(new Runnable() { public void run() { // TODO
// write the code to be executed after timer ends timer.cancel(); } }); } }; timer = new Timer(); timer.schedule(timerTask, DELAY); }
Comments
Post a Comment