Handler. sendmessage (new message) must send a new object

Source: Internet
Author: User

Handler. sendmessage (new message). This method means that handler needs to send a new object when sending a message. That is, after updating the date when sending a message, you need to reconstruct the message object instead of using the constructed object. Otherwise, an error is reported:

06-27 09:25:39. 073: Error/androidruntime (1170): Android. util. androidruntimeexception: {What = 0 when = 3496212 arg1 = 10 OBJ = android. graphics. drawable. animatedrotatedrawable @ 44f4b1a8} this message is already in use.
 

For example, the following code:

[Java: collapse: showcolumns]+
Expand sourceview
Plaincopy

··· · 50 ······· · 90 ····· · 140 · 150

    It seems correct, but an error is reported during running.

     

    The correct code should be:

    [Java: collapse: showcolumns]+
    Expand sourceview
    Plaincopy

    ··· · 50 ······· · 90 ····· · 140 · 150

       

      If you understand the message queue mechanism of handler, you will understand why "this message is already in use. "error, because each time the handler sendmessage () sends a message to a message-to-queue, it must be a new message object.

      Contact Us

      The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

      If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

      A Free Trial That Lets You Build Big!

      Start building with 50+ products and up to 12 months usage for Elastic Compute Service

      • Sales Support

        1 on 1 presale consultation

      • After-Sales Support

        24/7 Technical Support 6 Free Tickets per Quarter Faster Response

      • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.