Android Guides | Samples

Android.OS.Message Class

Defines a message containing a description and arbitrary data object that can be sent to a Handler.

See Also: Message

Syntax

[Android.Runtime.Register("android/os/Message", DoNotGenerateAcw=true)]
public sealed class Message : Object, IParcelable, IDisposable

Remarks

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.

[Android Documentation]

Requirements

Namespace: Android.OS
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1

The members of Android.OS.Message are listed below.

See Also: Object

Public Constructors

Constructor (but the preferred way to get a Message is to call Message.Obtain).

Public Properties

Arg1Int32. arg1 and arg2 are lower-cost alternatives to using Message.Data if you only need to store a few integer values.
Arg2Int32. arg1 and arg2 are lower-cost alternatives to using Message.Data if you only need to store a few integer values.
[read-only]
CallbackIRunnable. Retrieve callback object that will execute when this message is handled.
[read-only]
static
CreatorIParcelableCreator.
DataBundle. Obtains a Bundle of arbitrary data associated with this event, lazily creating it if necessary.
ObjObject. An arbitrary object to send to the recipient.
ReplyToMessenger. Optional Messenger where replies to this message can be sent.
SendingUidInt32. Optional field indicating the uid that sent the message.
TargetHandler. Retrieve the a Handler implementation that will receive this message.
WhatInt32. User-defined message code so that the recipient can identify what this message is about.
[read-only]
WhenInt64. Return the targeted delivery time of this message, in milliseconds.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

CopyFrom(Message)
Make this message like o.
DescribeContents() : Int32
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
static
Obtain() : Message
Return a new Message instance from the global pool.
static
Obtain(Handler) : Message
Same as Message.Obtain, but sets the value for the target member on the Message returned.
static
Obtain(Message) : Message
Same as Message.Obtain, but copies the values of an existing message (including its target) into the new one.
static
Obtain(Handler, IRunnable) : Message
Same as Message.Obtain(Handler), but assigns a callback Runnable on the Message that is returned.
static
Obtain(Handler, Action) : Message
static
Obtain(Handler, Int32) : Message
Same as Message.Obtain, but sets the values for both target and what members on the Message.
static
Obtain(Handler, Int32, Object) : Message
Same as Message.Obtain, but sets the values of the target, what, and obj members.
static
Obtain(Handler, Int32, Int32, Int32) : Message
Same as Message.Obtain, but sets the values of the target, what, arg1, and arg2 members.
static
Obtain(Handler, Int32, Int32, Int32, Object) : Message
Same as Message.Obtain, but sets the values of the target, what, arg1, arg2, and obj members.
PeekData() : Bundle
Like getData(), but does not lazily create the Bundle.
Recycle()
Return a Message instance to the global pool.
SendToTarget()
Sends this Message to the Handler specified by Message.Target.
WriteToParcel(Parcel, ParcelableWriteFlags)
Flatten this object in to a Parcel.