title: Schedule task in android
body: <p>I am using below code for scheduling a task in android but its not giving any results. Please advise on the same.</p>
  
  <pre><code>int delay = 5000; // delay for 5 sec.
  int period = 1000; // repeat every sec.
  Timer timer = new Timer();
  timer.scheduleAtFixedRate(new TimerTask() {
  
     public void run() {
        Toast.makeText(getApplicationContext(),"RUN!",Toast.LENGTH_SHORT).show();
     }
  
  }, delay, period);
  </code></pre>