共用方式為


Message Class

Definition

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

[Android.Runtime.Register("android/os/Message", DoNotGenerateAcw=true)]
public sealed class Message : Java.Lang.Object, Android.OS.IParcelable, IDisposable, Java.Interop.IJavaPeerable
[<Android.Runtime.Register("android/os/Message", DoNotGenerateAcw=true)>]
type Message = class
    inherit Object
    interface IParcelable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
Inheritance
Message
Attributes
Implements

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.

<p class="note">While the constructor of Message is public, the best way to get one of these is to call #obtain Message.obtain() or one of the Handler#obtainMessage Handler.obtainMessage() methods, which will pull them from a pool of recycled objects.</p>

Java documentation for android.os.Message.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Message()

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

Properties

Arg1

arg1 and arg2 are lower-cost alternatives to using #setData(Bundle) setData() if you only need to store a few integer values.

Arg2

arg1 and arg2 are lower-cost alternatives to using #setData(Bundle) setData() if you only need to store a few integer values.

Asynchronous

Returns true if the message is asynchronous, meaning that it is not subject to Looper synchronization barriers. -or- Sets whether the message is asynchronous, meaning that it is not subject to Looper synchronization barriers.

Callback

Retrieve callback object that will execute when this message is handled.

Class

Returns the runtime class of this Object.

(Inherited from Object)
Creator
Data

Obtains a Bundle of arbitrary data associated with this event, lazily creating it if necessary. -or- Sets a Bundle of arbitrary data values.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Obj

An arbitrary object to send to the recipient.

PeerReference (Inherited from Object)
ReplyTo

Optional Messenger where replies to this message can be sent.

SendingUid

Optional field indicating the uid that sent the message.

Target

Retrieve the android.os.Handler Handler implementation that will receive this message.

ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
What

User-defined message code so that the recipient can identify what this message is about.

When

Return the targeted delivery time of this message, in milliseconds.

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CopyFrom(Message)

Make this message like o.

DescribeContents()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Obtain()

Return a new Message instance from the global pool.

Obtain(Handler, Action)
Obtain(Handler, Int32, Int32, Int32, Object)

Same as #obtain(), but sets the values of the <em>target</em>, <em>what</em>, <em>arg1</em>, <em>arg2</em>, and <em>obj</em> members.

Obtain(Handler, Int32, Int32, Int32)

Same as #obtain(), but sets the values of the <em>target</em>, <em>what</em>, <em>arg1</em>, and <em>arg2</em> members.

Obtain(Handler, Int32, Object)

Same as #obtain(), but sets the values of the <em>target</em>, <em>what</em>, and <em>obj</em> members.

Obtain(Handler, Int32)

Same as #obtain(), but sets the values for both <em>target</em> and <em>what</em> members on the Message.

Obtain(Handler, IRunnable)

Same as #obtain(Handler), but assigns a callback Runnable on the Message that is returned.

Obtain(Handler)

Same as #obtain(), but sets the value for the <em>target</em> member on the Message returned.

Obtain(Message)

Same as #obtain(), but copies the values of an existing message (including its target) into the new one.

PeekData()

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 #getTarget.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WriteToParcel(Parcel, ParcelableWriteFlags)

Flatten this object in to a Parcel.

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to