Search code examples
androidandroid-handlerpostdelayed

cancelling a handler.postdelayed process


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 progress bar and cancel button.

My problem is I can't find a way to cancel the postDelayed task before the time elapses.


Solution

  • I do this to post a delayed runnable:

    myHandler.postDelayed(myRunnable, SPLASH_DISPLAY_LENGTH); 
    

    And this to remove it: myHandler.removeCallbacks(myRunnable);