title: Why my timer reset button works erroneuosly in timer app?
body: <p>I am relatively new to android. I thought creating a simple app like a timer would be a great way to start.</p>
  <p>I managed to create my simple timer app, but I ran into an issue.</p>
  <p>I got my app to start and pause, but I can't figure out how to reset it back to &quot;00:00:00&quot;. I tried the following on lines 56-59 in my Java code.</p>
  <pre><code>package com.awesomeapps.misael.timer;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.os.Handler;
  import android.os.SystemClock;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  
  public class MainActivity extends Activity {
  
      private Button startButton;
      private Button pauseButton;
  
      private TextView timerValue;
  
      private long startTime = 0L;
  
      private Handler customHandler = new Handler();
  
      long timeInMilliseconds = 0L;
      long timeSwapBuff = 0L;
      long updatedTime = 0L;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          timerValue = (TextView) findViewById(R.id.timerValue);
  
          startButton = (Button) findViewById(R.id.startButton);
  
          startButton.setOnClickListener(new View.OnClickListener() {
  
              public void onClick(View view) {
                  startTime = SystemClock.uptimeMillis();
                  customHandler.postDelayed(updateTimerThread, 0);
  
              }
          });
  
          pauseButton = (Button) findViewById(R.id.pauseButton);
  
          pauseButton.setOnClickListener(new View.OnClickListener() {
  
              public void onClick(View view) {
  
                  timeSwapBuff += timeInMilliseconds;
                  customHandler.removeCallbacks(updateTimerThread);
  
              }
          });
      }
      public void onButtonTapReset(View v)
      {
          timerValue.setText(&quot;00:00:00&quot;);
      }
  
      private Runnable updateTimerThread = new Runnable() {
  
          public void run() {
  
              timeInMilliseconds = SystemClock.uptimeMillis() - startTime;
  
              updatedTime = timeSwapBuff + timeInMilliseconds;
  
              int secs = (int) (updatedTime / 1000);
              int mins = secs / 60;
              secs = secs % 60;
              int milliseconds = (int) (updatedTime % 1000);
              timerValue.setText(&quot;&quot; + mins + &quot;:&quot;
                      + String.format(&quot;%02d&quot;, secs) + &quot;:&quot;
                      + String.format(&quot;%03d&quot;, milliseconds));
              customHandler.postDelayed(this, 0);
          }
  
      };
  
  }
  </code></pre>
  <p>When I press my reset button it does turn into &quot;00:00:00&quot; but when press my start button the timer resumes where it left off. Like for example if the timer is at &quot;00:05:123&quot; ill press reset and itll change to &quot;00:00:00&quot; but when I press start again it picks off where it left off or maybe even a little further like &quot;00:08:456&quot; it wont start over from zero when I press reset then start again.</p>
  <p>Can someone help me figure out my reset button, please?</p>
  <p>I've attached some files in which I think my error might be in including the Java code at the above.</p>
  <p>Strings xml file.</p>
  <pre><code>&lt;resources&gt;
      &lt;string name=&quot;app_name&quot;&gt;Timer&lt;/string&gt;
      &lt;string name=&quot;action_settings&quot;&gt;Settings&lt;/string&gt;
      &lt;string name=&quot;hello_world&quot;&gt;Hello world!&lt;/string&gt;
      &lt;string name=&quot;timerVal&quot;&gt;00:00:00&lt;/string&gt;
      &lt;string name=&quot;pauseButtonLabel&quot;&gt;Pause&lt;/string&gt;
      &lt;string name=&quot;startButtonLabel&quot;&gt;Start&lt;/string&gt;
  &lt;/resources&gt;
  </code></pre>
  <p>activity_main xml file</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:background=&quot;#000000&quot;
      android:layout_height=&quot;match_parent&quot; &gt;
      &lt;TextView
          android:id=&quot;@+id/timerValue&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_above=&quot;@+id/pauseButton&quot;
          android:layout_centerHorizontal=&quot;true&quot;
          android:layout_marginBottom=&quot;37dp&quot;
          android:textSize=&quot;40sp&quot;
          android:textColor=&quot;#ffffff&quot;
          android:text=&quot;@string/timerVal&quot; /&gt;
      &lt;Button
          android:id=&quot;@+id/startButton&quot;
          android:layout_width=&quot;90dp&quot;
          android:layout_height=&quot;45dp&quot;
          android:layout_alignParentLeft=&quot;true&quot;
          android:layout_centerVertical=&quot;true&quot;
          android:layout_marginLeft=&quot;38dp&quot;
          android:text=&quot;@string/startButtonLabel&quot; /&gt;
      &lt;Button
          android:id=&quot;@+id/pauseButton&quot;
          android:layout_width=&quot;90dp&quot;
          android:layout_height=&quot;45dp&quot;
          android:layout_alignBaseline=&quot;@+id/startButton&quot;
          android:layout_alignBottom=&quot;@+id/startButton&quot;
          android:layout_alignParentRight=&quot;true&quot;
          android:layout_marginRight=&quot;38dp&quot;
          android:text=&quot;@string/pauseButtonLabel&quot; /&gt;
  
      &lt;Button
          android:id=&quot;@+id/buttonReset&quot;
          android:layout_width=&quot;90dp&quot;
          android:layout_height=&quot;45dp&quot;
          android:text=&quot;Reset&quot;
          android:layout_below=&quot;@+id/timerValue&quot;
          android:layout_centerHorizontal=&quot;true&quot;
          android:onClick=&quot;onButtonTapReset&quot; /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p>I know my question is long, but I like being detailed.</p>