title: Android relaunching Timers after they are canceled
body: <p>I have a timer in my application that launches an AsyncTask every 15 secs.</p>
  
  <pre><code>Timer timer = new Timer();
  
  public void AsynchTaskTimer() {
      final Handler handler = new Handler();
  
      TimerTask timertask = new TimerTask() {
          @Override
          public void run() {
              handler.post(new Runnable() {
                  public void run() {
                      try {
                          new updateGPSTask().execute();
                      } catch (Exception e) {
                          // TODO Auto-generated catch block
                      }
                  }
              });
          }
      };
      timer.schedule(timertask, 0, 15000); // execute in every 15sec
  }
  </code></pre>
  
  <p>This is launched from the <code>onCreate()</code> method.</p>
  
  <p>When I call another activity I need to cancel this timer, which I did using <code>timer.cancel()</code> on my <code>onPause()</code> method in my Main Activity.</p>
  
  <p>Now when I return to the Main Activity I need to restart the timer. I tried relaunching the <code>AsynchTaskTimer()</code> in the <code>onRestart()</code> method, but I get a <code>java.lang.IllegalStateException: Timer was canceled</code>.</p>
  
  <p>How do I restart my timer? </p>