cancelling a handler.postdelayed process

后端 未结 6 1425
粉色の甜心
粉色の甜心 2020-11-28 19:27

I am using handler.postDelayed() to create a waiting period before the next stage of my app takes place. During the wait period I am displaying a dialog with pr

6条回答
  •  醉酒成梦
    2020-11-28 20:10

    In case you do have multiple inner/anonymous runnables passed to same handler, and you want to cancel all at same event use

    handler.removeCallbacksAndMessages(null);

    As per documentation,

    Remove any pending posts of callbacks and sent messages whose obj is token. If token is null, all callbacks and messages will be removed.

提交回复
热议问题