timerUploadTime = new Timer();
timerUploadTimeTask = new TimerTask() {
@Override public void run() {
mHandler.post(new Runnable() {
@Override
public void run() {
...
}
}
});
}
};
timerUploadTime.schedule(timerUploadTimeTask, 1, Integer.parseInt(Utils.loadStringValue(mycontext, "refresh")));
I'd like to change my timer's interval, in an other code segment. Is there a way to do that? I dont want to retiming my code, i would like to add a new "period" interval.
How can I do that after schedule?
You can't. You'll have to cancel the current task and reschedule.
You should cancel the timer before you can set a new schedule to it.
timerTask.cancel();
timerTask = new MyTimerTask();
timer.schedule(timerTask, delay);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With