On Sep 21, 1:19 am, Dianne Hackborn <[email protected]> wrote:

> And yes: the platform does this for you when done dispatching a message, so
> when you handler, you no longer own the message and should not touch that
> object any more.

That point isn't entirely clear in the docs, but it's definitely true
in practice. Just to clarify, you can READ the message that's passed
into the handler (at least for the duration of the handleMessage()
method), but you can't re-send it. If you need to re-send a message
from within a handler - something I find myself doing with surprising
frequency - you need a construct something like this:

        public void handleMessage(Message msg) {
                if (notReadyYet) {
                        Message newMsg = Message.obtain(msg);
                        sendMessageDelayed(newMsg, 100);
                        return;
                }

                ... real handler code here
        }

That'll make a copy of your original message and re-send it after a
delay of 100ms, and keep doing it until conditions (defined elsewhere)
are ready for the handler to do its work.

To relate this back to the original post :^), the original message
gets recycled after handleMessage() by the system, but you never need
to call recycle() yourself.

String

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to