java.lang.Object | |
↳ | android.os.Message |
Class Overview
Defines a message containing a description and arbitrary data object that can be sent to a Handler
. This object contains two extra int fields and an extra object field that allow you to not do allocations in many cases.
While the constructor of Message is public, the best way to get one of these is to call Message.obtain()
or one of the Handler.obtainMessage()
methods, which will pull them from a pool of recycled objects.
java.lang.Object | |
↳ | android.os.MessageQueue |
Class Overview
Low-level class holding the list of messages to be dispatched by a Looper
. Messages are not added directly to a MessageQueue, but rather through MessageQueue.IdleHandler
objects associated with the Looper.
You can retrieve the MessageQueue for the current thread with Looper.myQueue()
.
定义一个消息包含一个描述和任意的数据对象,可以发送到处理程序。这个对象包含两个额外的int类型和一个额外的object雷翔允许你在许多情况下不分配。
当消息的贡枣函数是公共的,最好的途径之一就是去调用Message.obtain()或者一个Handler.obtainMessage()
方法,这将把他们从池中回收对象。
Low-Level类列出了消息列表通过Looper被发送。消息不是MessageQueue直接添加,二回通过与Looper相关的MessageQueue.IdleHandler对象。
您可以检索当前线程的消息队列通过 Looper.myQueue()方法。