Android Handler Official description

Source: Internet
Author: User

Official API Document: Https://developer.android.google.cn/reference/android/os/Handler

Handler allows you to send and process message and runnable objects associated with the MessageQueue of a thread. Each handler instance is associated with a single thread and Message Queuing for that thread. When a new handler object is created, it is bound to the message queue that created his thread and thread, and then handler passes the message and adds it to the message queue and processes and executes it in the message queue.

The handler has two main functions:

    • Schedule a message or runnable to execute somewhere in a main thread;
    • Schedule an action to be executed in a different thread.

The methods for dispatching messages include:

Post (Runnable R) Add the Runnable object R to the message queue
Postattime (Runnable R, Long Uptimemillis) Adds the Runnable object R to the message queue and executes at the time the Uptimemillis is set
Postdelayed (Runnable R, Long Delaymillis) Adds the Runnable object R to the message queue and executes after a delay of Delaymillis
Sendemptymessage (int what) Send an empty message containing only the What property
SendMessage (Message msg) Add a message to the end of the queue for the message you are waiting for
Sendmessageattime (Message msg, long Uptimemillis) Adds a message to the end of the queue of a waiting message at a specified time Uptimemillis
Sendmessagedelayed (Message, long) Add a message to the end of the queue of a waiting message after the delay Delaymillis

Android Handler Official description

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.