Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pause handler.postDelayed() timer on Android

How can i pause the handler.postDelayed() timer using a button. So when i click the same button again the handler.postDelayed() timer should resume.

handler.postDelayed(counterz, 60);
like image 893
Sai Avatar asked Jul 03 '13 03:07

Sai


1 Answers

Handler does not have a timer to tweak. You are posting to event-queue of a thread, where a lot of other stuff is running as well.

You can cancel posted Runnable's:

handler.removeCallbacks(counterz);

And post again, to resume.

like image 155
S.D. Avatar answered Nov 01 '22 16:11

S.D.