title: cancel Timer out from method
body: <p>I have a problem with canceling this timer out of this method.</p>
  
  <pre><code> public void nezablokovat() {
      int secondsToRun = 9999999;
      final ValueAnimator timern = ValueAnimator.ofInt(secondsToRun);
      timern.setDuration(secondsToRun * 1000).setInterpolator(new LinearInterpolator());
      timern.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
              int elapsedSeconds = (int) animation.getAnimatedValue();
              int minutes = elapsedSeconds / 60;
              int seconds = elapsedSeconds % 60;
  
              if (seconds%10 == 1) {
                  Pis("$$$");
              }
          }
  
          });
          timern.start();
      }
  </code></pre>
  
  <p>I want to put <code>timern.cancel();</code> to an other method in the <code>onClick</code> Listener for the Button. 
  Please Do you have some ideas? </p>
  
  <p>If I put <code>timern.cancel()</code> here:</p>
  
  <pre><code>void teplotahore() {
      STup.setOnClickListener(
              new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      timern.cancel();
                      }
                  }
              }
  
      );
  }
  </code></pre>
  
  <p>The compiler doesn't know <code>timern</code>. </p>