I am using a while loop with a timer. The thing is that the timer is not used in every loop. It is used only the first time. After the first time the statements included inside
You're scheduling 10 TimerTask
s to execute after an hour, at the same time. So all 10 tasks are being executed after 1 hour, which makes it seem like 1 execute since all the Toast
messages display at the same time. To schedule tasks at a fixed delay, with the first task starting in 1 hour, use this method:
Timer t = new Timer();
t.schedule(task, 3600000, 3600000);
This will execute until you call t.cancel()
.