You have to create a new TimerTask object everytime you restart the Timer.
So, create a new one on Start. And Destroy the Timer with "Timer.cancel" and "Timer.purge".
For eg, I have two Buttons - Start and Stop
mStartButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mTimerTask = new TimerTask();//This creates new TimerTask
timer = new Timer(); //Instantiate again, as we Cancel the Timer
timer.schedule(mTimerTask, 0, 30);
}
});
mEndButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
timer.cancel();
timer.purge();
}
});