I want to know what is the exact meaning of removeCallbacks(Runnable r) in Handler. I gone through its documentation and it simply says "Remove any pending posts of Runnable r that are in the message queue".
Now my question is if my message has already been started processing by my handler and in between if I call removeCallbacks
, will it stop processing my half completed message? Or even if I call removeCallbacks
the message which has already started processing by my handler (when I call post(Runnable r)
) will be executed?
When you create a new Handler
, it is bound to the thread / message queue of the thread that is creating it. From that point on, it will deliver messages and runnables to that message queue and execute them as they come out of the message queue. removeCallbacks
simply removes those runnables who have not yet begun processing from the queue.