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.
Runnables should only be executed as they come out of the message queue, so if your message has already started processing it should not be effected by calling removeCallbacks
. It should have already been removed, so it will continue processing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With