Configure the tenth timer repeater and update the view in the runnable handler.
protected Timer timeTicker= new Timer("Ticker");
private Handler timerHandler = new Handler();
protected int timeTickDown = 10;
timeTicker.scheduleAtFixedRate(tick, 0, 100);
protected TimerTask tick = new TimerTask() {
public void run() {
myTickTask();
}
};
protected void myTickTask() {
if (timeTickDown == 0) {
timerHandler.post(doUpdateTimeout);
}
timeTickDown--;
}
private Runnable doUpdateTimeout = new Runnable() {
public void run() {
updateTimeout();
}
};
private void updateTimeout() {
timeTickDown = 10;
}
source
share