Why does the timer stop working when i put the postDelayed(this,1000); inside the if statement,just under seconds++;?
Like this....
If(running){
seconds++;
postDelayed(this,1000);
}
Because postDelayed() is what causes the next cycle of the timer to happen. In your case it schedules the timer to go off 1000 milliseconds in the future. So if you only do that when running is true, then as soon as you set running to false, you no longer tell the timer to keep going.
So postdelayed() method causes the timer to keep looping?when i read about postdelayed method online.it only says that it will cause the delay of execution...how about post() method?
So you mean that in default running is false,so postdelayed wont execute.thus the loop stops.am i right?