title: Android Timer/CountDownTimer execute on onResume(
body: <p>I'm doing a small android application. I want that when the application stops, a timer or a countdowntimer is launched, and after a time (30 seconds) it executes an action, in my case closing connection with a server.
  This works perfectly, the problem is that when you resume the application, the timer/countdowntimer is launched again, and I do not want that.</p>
  
  <p>this is my code:</p>
  
  <pre><code>@Override
  protected void onStop() {
  
      super.onStop();
      desconexionTimer = new Timer();
      desconexionTimer.schedule(new TimerTask() {
          @Override
          public void run() {
              new ThreadDesconexion(this).execute();
          }
      }, 30 * 1000);
  
  } 
  
  @Override
  protected void onResume() {
  
      super.onResume();
      if(!ConexionServer.threIsConexion()){
           comeActivityLogin();
       }  
  }
  </code></pre>
  
  <p>I try use a CountDownTimer and happen the same.</p>
  
  <pre><code>@Override
  protected void onStop() {
  
      super.onStop();
      new CountDownTimer(30000, 1000) {
            public void onTick(long millisUntilFinished) {
                Log.d("INFO","HELLO");
            }
  
            public void onFinish() {
                new ThreadDesconexion(this).execute()     }
     }.start();
  } 
  </code></pre>
  
  <p>I'm doing something wrong? or there's some way to do this?
  thank you very much</p>