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.
翻译:
定义一个消息包含一个描述和任意的数据对象,可以发送到处理程序。这个对象包含两个额外的int字段和一个额外的对象字段允许您在许多情况下不分配。
虽然公共消息的构造函数,得到其中一个最好的方法是调用Message.obtain Handler.obtainMessage之一()或()方法,它将把他们从池中回收的对象。
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Message()
Constructor (but the preferred way to get a Message is to call
Message.obtain() ).
|
public int arg1
arg1 and arg2 are lower-cost alternatives to using setData()
if you only need to store a few integer values.
使用__arg1和包括低成本替代品setData()如果你只需要存储一些整数值。
public int arg2
arg1 and arg2 are lower-cost alternatives to using setData()
if you only need to store a few integer values.
这里面可以查看源码为什么不用Message message = new Message();