I want to set a countdown timer for 30s seconds. After 30 seconds I want it to do (whatever) and then loop and start the 30 second countdown again.
Asked
Active
Viewed 1,610 times
1
-
sorry i am not clear about your question you need delay 30 seconds delay ? can u give more clarity your question. – Ravi Jaggarapu Dec 18 '15 at 11:47
2 Answers
1
new CountDownTimer(30000, 1000)
{
public void onTick(long millisUntilFinished)
{
tv_timer.setText("seconds remaining: " + millisUntilFinished / 1000);
}
public void onFinish()
{
//do your stuff and at end of that stuff again call CountDownTimer method
}
}.start();

Mayuresh Gawande
- 197
- 10
0
You may try this one.
private final Handler mHandler = new Handler();
private final int delay = 30 * 1000; //30 secs
private void startCountDown(){
mHandler.postDelayed(task, delay);
}
private Runnable task = new Runnable() {
@Override
public void run() {
//do something...
if (true) { //condition to continue...
mHandler.postDelayed(this, delay);
}
}
};

Ocor Kcirad
- 354
- 2
- 4