title: Save and show chronometer data in another activity
body: <p>I've been working on this project for the past few days and now I encountered an error. I've searched on google and stackoverflow for solutions but they didn't help (or I do not know how to fix it).</p>
  
  <p>I'm trying to save the data from the chronometer from <code>TimerActivity</code> after I press the button "stop" and make it appear on <code>HistoryActivity</code>.</p>
  
  <p><strong>TimerActivity</strong></p>
  
  <pre><code>public class TimerActivity extends AppCompatActivity {
      Toolbar toolbar;
  
      private ImageButton imgbtnPause;
      private ImageButton imgbtnReset;
      private ImageButton imgbtnStart;
      private ImageButton imgbtnStop;
      private Chronometer mChronometer;
  
  
      long saveTime;
      private long lastPause;
  @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_timer);
  
          toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          imgbtnPause = (ImageButton) findViewById(R.id.imgButtonPause);
          imgbtnReset = (ImageButton) findViewById(R.id.imgButtonReset);
          imgbtnStart = (ImageButton) findViewById(R.id.imgButtonStart);
          imgbtnStop = (ImageButton) findViewById(R.id.imgButtonStop);
  
          mChronometer = (Chronometer) findViewById(R.id.chronometer);
  mChronometer.setText("00:00:00");
          mChronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
  
              @Override
              public void onChronometerTick(Chronometer chronometer) {
                  CharSequence text = chronometer.getText();
                  if (text.length() == 5) {
                      chronometer.setText("00:" + text);
                  } else if (text.length() == 7) {
                      chronometer.setText("0" + text);
                  }
              }
          });
  
          imgbtnStart.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (lastPause != 0) {
                      mChronometer.setBase(mChronometer.getBase() + SystemClock.elapsedRealtime() - lastPause);
                  } else {
                      mChronometer.setBase(SystemClock.elapsedRealtime());
                  }
                  mChronometer.start();
                  imgbtnStart.setEnabled(false);
                  imgbtnPause.setEnabled(true);
              }
          });
  
          imgbtnPause.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  lastPause = SystemClock.elapsedRealtime();
                  mChronometer.stop();
                  imgbtnPause.setEnabled(false);
                  imgbtnStart.setEnabled(true);
              }
          });
  
          imgbtnReset.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  mChronometer.stop();
                  mChronometer.setBase(SystemClock.elapsedRealtime());
                  lastPause = 0;
                  imgbtnStart.setEnabled(true);
                  imgbtnPause.setEnabled(false);
              }
          });
  
      imgbtnStop.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  mChronometer.stop();
                  final AlertDialog.Builder builder = new AlertDialog.Builder(TimerActivity.this);
                  builder.setTitle("Stop alert");
                  builder.setMessage("Have you finished working mate?");
                  builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          mChronometer.stop();
                          mChronometer.setBase(SystemClock.elapsedRealtime());
                          imgbtnStart.setEnabled(true);
                          final AlertDialog.Builder builder1 = new AlertDialog.Builder(TimerActivity.this);
                          builder1.setTitle("Save");
                          builder1.setMessage("Do you want to save your progress mate?");
                          builder1.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
  
                                  saveTime = SystemClock.elapsedRealtime() - mChronometer.getBase();
                                  String seconds = String.valueOf(saveTime);
                                  Intent i = new Intent(getApplicationContext(), HistoryActivity.class);
                                  i.putExtra("Timer", seconds);
                                  startActivity(i);
  
                                  mChronometer.stop();
                                  mChronometer.setBase(SystemClock.elapsedRealtime());
                                  imgbtnStart.setEnabled(true);
                              }
                          });
  @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.timer_menu, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          int id = item.getItemId();
  
          if (id == R.id.id_language) {
              Toast.makeText(this, "Language is clicked", Toast.LENGTH_SHORT).show();
          } else if (id == R.id.id_logout) {
              Intent intent = new Intent(TimerActivity.this, MainActivity.class);
              startActivity(intent);
          } else if (id == R.id.id_history) {
              Intent intent2 = new Intent(TimerActivity.this, HistoryActivity.class);
              startActivity(intent2);
          }
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p><strong>TimerActivity xml</strong></p>
  
  <pre><code>&lt;Chronometer
          android:id="@+id/chronometer"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginEnd="8dp"
          android:layout_marginStart="8dp"
          android:layout_marginTop="192dp"
          android:textColor="#e78200"
          android:textSize="32sp"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  </code></pre>
  
  <p>and plus four Image Buttons (start, stop, pause and reset).</p>
  
  <p><strong>HistoryActivity</strong></p>
  
  <pre><code>public class HistoryActivity extends AppCompatActivity{
  
          TextView textView;
          Toolbar toolbar_h;
      @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_history);
  
              toolbar_h = (Toolbar) findViewById(R.id.toolbar_history);
              setSupportActionBar(toolbar_h);
  
              Bundle extras = getIntent().getExtras();
              if (extras != null) {
                  String value = extras.getString("Timer");
                  //The key argument here must match that used in the other activity
              }
  public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.history_menu, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          int id = item.getItemId();
  
          if (id == R.id.id_language) {
              Toast.makeText(this, "Language is clicked", Toast.LENGTH_SHORT).show();
          } else if (id == R.id.id_logout) {
              Intent intent = new Intent(HistoryActivity.this, MainActivity.class);
              startActivity(intent);
          }else if (id == R.id.id_timer){
              Intent intent2 = new Intent(HistoryActivity.this, TimerActivity.class);
              startActivity(intent2);
          }
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p><code>HistoyActivity XML</code> has only one <code>TextView</code>.</p>
  
  <p>How can I make the saved chronometer data appear on <code>HistoryActivity</code>?</p>
  
  <p>Thank you</p>