thedarkpassenger
thedarkpassenger

Reputation: 7348

How to stop a timer in android

How to stop the currently executing task of the timer.? If i use timer.cancel() it will cancel the timer but perform the currently executing task..So is there a way around so that i can cancel the currently executing task??

Upvotes: 3

Views: 6658

Answers (2)

Imran Rana
Imran Rana

Reputation: 11889

Use:

   timer.cancel();
   timer.purge() 

purge() Removes all canceled tasks from the task queue and timer.cancel() cancels the Timer and all scheduled tasks..


Also take a look at This post

Upvotes: 3

Alexander Lucas
Alexander Lucas

Reputation: 22361

Follow the cancel call with a

timer.purge();

Upvotes: 4

Related Questions