title: Stop handler after closing and open the applicaiton in Android
body: <p>I'm trying to stop Handler, after closing and then open the application again, but I don't know how, so can someone explain me, what I have to do in this situation?
  I have the following method.</p>
  
  <pre><code>private Handler handler = new Handler();  
  private Timer timer = new Timer(); 
  private TimerTask timerTask;
  
  private void openHandler(){
       timerTask = new TimerTask() {
           public void run() { 
              handler.post(myRunnable = new Runnable() {
                  public void run() {
  
                              doSomething();                                                                                                                                                      
  
                  }           
              });                                 
           }       
       };             
       timer.schedule(timerTask, min*60000);                                          
       dialog.dismiss();                                                   
       btnToggleTimer.setClickable(true); 
  }
  </code></pre>
  
  <p>I call this method from a toggleButton:</p>
  
  <pre><code>btnToggleTimer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked1) {  
  
                       btnToggleTimer.setClickable(false)
  
                        if(isCheked1){
  
                                 openHandler();
                   }
                }
           });
  </code></pre>
  
  <p>The handler will stop, for example after 5 minutes, but if I want to stop it before this 5 minutes, after closing my app and open it again, What can I do about it?</p>