0

i am having 2 activities right now, the first one contain a "start" button, and when user press start, it will go to the second activity by

Intent myIntent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(myIntent); 
overridePendingTransition(R.anim.slide_in_right,R.anim.slide_out_left);

and when the second activity starts, it automatically starts a CountDownTimer which i have

        countDownTimer = new MalibuCountDownTimer(startTime, interval);
    countDownTimer.start();

inside OnCreate of the second activity. Currectly startTime is 20 second, and I have it displayed onto a textview with this

 text.setText(""+String.format("%02d:%02d:%03d",
                    TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millisUntilFinished)),
                    TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished)),
                    TimeUnit.MILLISECONDS.toMillis(millisUntilFinished) - TimeUnit.SECONDS.toMillis(TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished))
                    ));

However, when the second activity starts, the time would show something like

00:19:674

something like that, like it would never starts at 00:20:000, is there a way to fix this problem?

Thanks

cutecutebj
  • 179
  • 1
  • 15
  • Try to use fragments, those are always good where you want the tracking data thing...Once you use fragments you will love that how fragments makes complicated things pretty simple... – Jyo the Whiff Jan 22 '16 at 04:05
  • Have you looked at this post? http://stackoverflow.com/questions/12762272/android-countdowntimer-additional-milliseconds-delay-between-ticks – childofthehorn Jan 22 '16 at 04:06

1 Answers1

0

You can put countDownTimer.start() and textview.setText() in onResume() instead of onCreate()