Friday, April 12, 2013

Re: [android-developers] Re: handler.removeMessages(0) removes all runnable added by handler.post().

Yes, that's what I mean. What I didn't know was that
Even though I never set 'what' value to 0 in handler.post(new Runnable()),
The runnable is removed. (The doc didn't say default value of 'what' is 0!!!)



2013/4/12 bob <bob@coolfone.comze.com>

That code does not remove the 0th Message.


It removes all messages that have a "what" value of 0.  


The "what" is apparently an id associated with the messages (not necessarily unique) :



Thanks.



On Thursday, April 11, 2013 8:20:06 PM UTC-5, NoraBora wrote:
Sometimes you use a handler as a member variable and use it for sendMessages(), removeMessage(), post().
I just found out something.

Say you call these
    handler.sendMesssage(0) // 1
    handler.post(new Runnable()) // 2
    handler.post(new Runnable()) // 3

and call this
    handler.removeMessage(0)

then this will remove 2, 3 as well as 1
because removeMessage/hasMessage doesn't check runnable and posted message's what value is 0 by default.

Some people could think this as a bug but it's too late to change such a basic api so
I think documentation should mention this.

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Android Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-developers/9kiGk35F-Ik/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups "Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate