title: app is crashing as soon as countDownTimer.cancel() is called
body: <p>My timer app is crashing as soon as <code>countDownTimer.cancel()</code> method is called
  it is showing null object reference even though I have done it correctly, I can't find the problem.
  Please, someone, take a look on the code below : (also I am attaching logcat)</p>
  <blockquote>
  <p>Caused by: java.lang.NullPointerException: Attempt to invoke virtual
  method 'void android.os.CountDownTimer.cancel()' on a null object
  reference</p>
  </blockquote>
  <pre><code>package com.example.rajdeepkgautam.itimer;
  
  import android.media.MediaPlayer;
  import android.os.CountDownTimer;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.SeekBar;
  import android.widget.TextView;
  
  public class MainActivity extends AppCompatActivity {
  
  int max = 600;
  int start = 30;
  
  TextView timerTextView;
  SeekBar timerSeekBar;
  boolean timerActive = false;
  Button runButton;
  CountDownTimer countDownTimer;
  
  public void resetTimer() {
  
      timerTextView.setText(&quot;0:30&quot;);
      timerSeekBar.setProgress(start);
      timerSeekBar.setEnabled(true);
      countDownTimer.cancel();
      runButton.setText(&quot;RUN!&quot;);
      timerActive = false;
  
  }
  
  public void buttonClicked(View view) {
  
      if(timerActive) {
  
          resetTimer();
  
      } else {
  
              timerActive = true;
              runButton.setText(&quot;STOP!&quot;);
              timerSeekBar.setEnabled(false);
  
              CountDownTimer countDownTimer = new CountDownTimer((timerSeekBar.getProgress()*1000) + 100, 1000) {
                  @Override
                  public void onTick(long l) {
  
                      TimerUpdate((int) l/1000);
  
                  }
  
                  @Override
                  public void onFinish() {
  
                      MediaPlayer mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.horn);
                      mediaPlayer.start();
                      resetTimer();
  
                  }
              }.start();
  
  
  
          }
  }
  
  
  
  public void TimerUpdate(int TimeLeft) {
  
      int minutes = TimeLeft/60;
      int seconds = TimeLeft - (minutes*60);
  
      if(seconds &lt;=9) {
  
          timerTextView.setText(Integer.toString(minutes) + &quot;:&quot; + &quot;0&quot; + Integer.toString(seconds));
  
      } else {
  
          timerTextView.setText(Integer.toString(minutes) + &quot;:&quot; + Integer.toString(seconds));
  
      }
  
  
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      timerSeekBar = findViewById(R.id.timerSeekBar);
      timerTextView = findViewById(R.id.timerTextView);
      runButton = findViewById(R.id.runButton);
  
  
  
      timerSeekBar.setMax(max);
      timerSeekBar.setProgress(start);
  
  
      timerSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          @Override
          public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
  
              TimerUpdate(i);
  
          }
  
          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
  
          }
  
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
  
          }
      });
  
  }
  }
  </code></pre>