|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.os.Message
public final class Message
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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface android.os.Parcelable |
|---|
Parcelable.Creator<T> |
| Field Summary | |
|---|---|
int |
arg1
arg1 and arg2 are lower-cost alternatives to using setData()
if you only need to store a few integer values. |
int |
arg2
arg1 and arg2 are lower-cost alternatives to using setData()
if you only need to store a few integer values. |
(package private) Runnable |
callback
|
static Parcelable.Creator<Message> |
CREATOR
|
(package private) Bundle |
data
|
(package private) Message |
next
|
Object |
obj
An arbitrary object to send to the recipient. |
Messenger |
replyTo
Optional Messenger where replies to this message can be sent. |
(package private) Handler |
target
|
int |
what
User-defined message code so that the recipient can identify what this message is about. |
(package private) long |
when
|
| Fields inherited from interface android.os.Parcelable |
|---|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE |
| Constructor Summary | |
|---|---|
Message()
Constructor (but the preferred way to get a Message is to call Message.obtain()). |
|
| Method Summary | |
|---|---|
(package private) void |
clearForRecycle()
|
void |
copyFrom(Message o)
Make this message like o. |
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation. |
Runnable |
getCallback()
Retrieve callback object that will execute when this message is handled. |
Bundle |
getData()
Obtains a Bundle of arbitrary data associated with this event, lazily creating it if necessary. |
Handler |
getTarget()
Retrieve the a Handler implementation that
will receive this message. |
long |
getWhen()
Return the targeted delivery time of this message, in milliseconds. |
static Message |
obtain()
Return a new Message instance from the global pool. |
static Message |
obtain(Handler h)
Same as obtain(), but sets the value for the target member on the Message returned. |
static Message |
obtain(Handler h,
int what)
Same as obtain(), but sets the values for both target and
what members on the Message. |
static Message |
obtain(Handler h,
int what,
int arg1,
int arg2)
Same as obtain(), but sets the values of the target, what,
arg1, and arg2 members. |
static Message |
obtain(Handler h,
int what,
int arg1,
int arg2,
Object obj)
Same as obtain(), but sets the values of the target, what,
arg1, arg2, and obj members. |
static Message |
obtain(Handler h,
int what,
Object obj)
Same as obtain(), but sets the values of the target, what, and obj
members. |
static Message |
obtain(Handler h,
Runnable callback)
Same as obtain(Handler), but assigns a callback Runnable on
the Message that is returned. |
static Message |
obtain(Message orig)
Same as obtain(), but copies the values of an existing
message (including its target) into the new one. |
Bundle |
peekData()
Like getData(), but does not lazily create the Bundle. |
void |
recycle()
Return a Message instance to the global pool. |
void |
sendToTarget()
Sends this Message to the Handler specified by getTarget(). |
void |
setData(Bundle data)
Sets a Bundle of arbitrary data values. |
void |
setTarget(Handler target)
|
String |
toString()
Returns a string containing a concise, human-readable description of the receiver. |
void |
writeToParcel(Parcel dest,
int flags)
Flatten this object in to a Parcel. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public int what
Handler has its own name-space
for message codes, so you do not need to worry about yours conflicting
with other handlers.
public int arg1
setData()
if you only need to store a few integer values.
public int arg2
setData()
if you only need to store a few integer values.
public Object obj
public Messenger replyTo
long when
Bundle data
Handler target
Runnable callback
Message next
public static final Parcelable.Creator<Message> CREATOR
| Constructor Detail |
|---|
public Message()
Message.obtain()).
| Method Detail |
|---|
public static Message obtain()
public static Message obtain(Message orig)
obtain(), but copies the values of an existing
message (including its target) into the new one.
orig - Original message to copy.
public static Message obtain(Handler h)
obtain(), but sets the value for the target member on the Message returned.
h - Handler to assign to the returned Message object's target member.
public static Message obtain(Handler h,
Runnable callback)
obtain(Handler), but assigns a callback Runnable on
the Message that is returned.
h - Handler to assign to the returned Message object's target member.callback - Runnable that will execute when the message is handled.
public static Message obtain(Handler h,
int what)
obtain(), but sets the values for both target and
what members on the Message.
h - Value to assign to the target member.what - Value to assign to the what member.
public static Message obtain(Handler h,
int what,
Object obj)
obtain(), but sets the values of the target, what, and obj
members.
h - The target value to set.what - The what value to set.obj - The object method to set.
public static Message obtain(Handler h,
int what,
int arg1,
int arg2)
obtain(), but sets the values of the target, what,
arg1, and arg2 members.
h - The target value to set.what - The what value to set.arg1 - The arg1 value to set.arg2 - The arg2 value to set.
public static Message obtain(Handler h,
int what,
int arg1,
int arg2,
Object obj)
obtain(), but sets the values of the target, what,
arg1, arg2, and obj members.
h - The target value to set.what - The what value to set.arg1 - The arg1 value to set.arg2 - The arg2 value to set.obj - The obj value to set.
public void recycle()
public void copyFrom(Message o)
public long getWhen()
public void setTarget(Handler target)
public Handler getTarget()
Handler implementation that
will receive this message. The object must implement
Handler.handleMessage(). Each Handler has its own name-space for
message codes, so you do not need to
worry about yours conflicting with other handlers.
public Runnable getCallback()
Handler that is receiving this Message to
dispatch it. If
not set, the message will be dispatched to the receiving Handler's
Handler.handleMessage(Message Handler.handleMessage()).
public Bundle getData()
setData(Bundle).
public Bundle peekData()
public void setData(Bundle data)
public void sendToTarget()
getTarget().
Throws a null pointer exception if this field has not been set.
void clearForRecycle()
public String toString()
Object
toString in class Objectpublic int describeContents()
Parcelable
describeContents in interface Parcelable
public void writeToParcel(Parcel dest,
int flags)
Parcelable
writeToParcel in interface Parcelabledest - The Parcel in which the object should be written.flags - Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||