I am using a handler in the following program and I want to stop it when i=5 but the handler doesn\'t stop and run continuously.
b1.setOnClickListener(ne
Just saw this question. I would use CountDownTimer() instead. Run it for 5 seconds total and every second:
new CountDownTimer(5000, 1000) {
public void onTick(long milsecRemain) {
// Code to run every second
Log.i("Seconds left", String.valueOf(milsecRemain/1000));
}
public void onFinish() {
// 10 seconds have passed
}
}.start();