Код: Выделить всё
long timerDuration = Long.MAX_VALUE; // Use a very large number to simulate indefinite counting
// Create and start the CountDownTimer
breakTimer = new CountDownTimer(timerDuration, 1000) { // Count down in intervals of 1 second
@Override
public void onTick(long millisUntilFinished) {
// Increment the break time
// Calculate hours, minutes, and seconds
int h = totalBreakSeconds / 3600;
int m = (totalBreakSeconds % 3600) / 60;
int s = totalBreakSeconds % 60;
// Update the UI
breakHours.setText(String.format("%02d", h));
breakMinutes.setText(String.format("%02d", m));
breakSeconds.setText(String.format("%02d", s));
totalBreakSeconds++;
}
@Override
public void onFinish() {
// You can implement logic here if you want to handle the end of the timer
// For this use case, it will not reach here because of Long.MAX_VALUE
}
}.start();
Подробнее здесь: https://stackoverflow.com/questions/792 ... e-15-20-mi