Reputation: 1
Hi I am making countdown timer. And when I put value of minutes less than one minute everything works correctly. But when I put value for example 1:05 min and click start I see counting down from 1:44. And this problem always appears when I put value bigger than 1 minute
//rundowy czasomierz {
mCountDownTimer = new CountDownTimer(millisInput, 1000) {
@Override
public void onTick(long millisUntilFinished) {
mTimeLeftInMillis = millisUntilFinished;
updateCountDownText();
tv4.setText((round_count[0]+1)+"/"+finalNum_rounds);
}
@Override
public void onFinish() {
round_count[0]++;
if (round_count[0]<finalNum_rounds){
Handler handler=new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
start();
}
}, przerwasinput);
}
MediaPlayer ring = MediaPlayer.create(Main6Activity.this, R.raw.ring1);
ring.start();
tv3.setText("Przerwa");
if (!tv1.equals("00:00")) {
tv1.setText("Koniec");
}
private void updateCountDownText(){
int hours = (int) (mTimeLeftInMillis / 1000) / 3600;
int minutes = (int) ((mTimeLeftInMillis / 1000) % 3600) / 60;
int seconds = (int) (mTimeLeftInMillis / 1000) % 60;
String timeLeftFormatted;
timeLeftFormatted = String.format(Locale.getDefault(),
"%02d:%02d", minutes, seconds);
tv1.setText(timeLeftFormatted);
}
Upvotes: 0
Views: 31
Reputation: 131
My best guess is that your program interprets an input of 1:05 as 105 seconds. This is equal to 1 minute and 45 seconds, so your timer would begin counting down from 1:45.
I don't see where in your code you process input, so I don't know exactly what is causing this.
Upvotes: 2