Talk Android together now (one hundred seventy-two back to the first: Android's Handler mechanism a)

Tell me what you were Hello, everybody, let's say on a gyrus is an example of variable parameters in Java, this time we said examples are Android Handler mechanism of Gossip Hugh mentioned, words Reformed turn. Let's Talk Android now!

Tell me, today we want to introduce Handler mechanism, also called message mechanism, although different names, but the content is the same. It is an asynchronous mechanism provided by Android, which allows the main thread and the child thread to communicate. Next we detail what is the message mechanism.

This mechanism involves four main categories:Message,MessageQueue,Looper,Handler.

  • Messsage type of message, it encapsulates the specific content of the message and the message class;
  • MessageQueue message queue is located.
  • Handler is an operational message class, a message used to send and retrieve messages to the message queue, and the core function is a response message is processed differently for different messages.
  • looper to manage message queues, which contains the message queue members, it also used to manage threads, reflected the phenomenon is to deliver the message sent from the child thread to the main thread Handler to deal with.

Tell me, on Android Handler mechanism in case we described here, and there are any examples For, Let's hear next decomposition!

Published 528 original articles · won praise 131 · views 620 000 +

Guess you like

Origin blog.csdn.net/talk_8/article/details/105162482