Android
android.os
public final class

android.os.Messenger

java.lang.Object
android.os.Messenger Parcelable

Reference to a Handler, which others can use to send messages to it. This allows for the implementation of message-based communication across processes, by creating a Messenger pointing to a Handler in one process, and handing that Messenger to another process.

Summary

Constants

      Value  
Creator<Messenger CREATOR       
Constants inherited from interface android.os.Parcelable

Public Constructors

            Messenger(Handler target)
Create a new Messenger pointing to the given Handler.
            Messenger(IBinder target)
Create a Messenger from a raw IBinder, which had previously been retrieved with getBinder().

Public Methods

          int  describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
          boolean  equals(Object otherObj)
Comparison operator on two Messenger objects, such that true is returned then they both point to the same Handler.
          IBinder  getBinder()
Retrieve the IBinder that this Messenger is using to communicate with its associated Handler.
          int  hashCode()
Returns an integer hash code for the receiver.
      static    Messenger  readMessengerOrNullFromParcel(Parcel in)
Convenience function for reading either a Messenger or null pointer from a Parcel.
          void  send(Message message)
Send a Message to this Messenger's Handler.
      static    void  writeMessengerOrNullToParcel(Messenger messenger, Parcel out)
Convenience function for writing either a Messenger or null pointer to a Parcel.
          void  writeToParcel(Parcel out, int flags)
Flatten this object in to a Parcel.
Methods inherited from class java.lang.Object
Methods inherited from interface android.os.Parcelable

Details

Constants

public static final Creator<Messenger> CREATOR

Public Constructors

public Messenger(Handler target)

Create a new Messenger pointing to the given Handler. Any Message objects sent through this Messenger will appear in the Handler as if Handler.sendMessage(Message) had be called directly.

Parameters

target The Handler that will receive sent messages.

public Messenger(IBinder target)

Create a Messenger from a raw IBinder, which had previously been retrieved with getBinder().

Parameters

target The IBinder this Messenger should communicate with.

Public Methods

public int describeContents()

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

public boolean equals(Object otherObj)

Comparison operator on two Messenger objects, such that true is returned then they both point to the same Handler.

Parameters

otherObj Object the object to compare with this object.

Returns

  • boolean true if the object is the same as this object false if it is different from this object.

public IBinder getBinder()

Retrieve the IBinder that this Messenger is using to communicate with its associated Handler.

Returns

  • Returns the IBinder backing this Messenger.

public int hashCode()

Returns an integer hash code for the receiver. Any two objects which answer true when passed to .equals must answer the same value for this method.

Returns

  • int the receiver's hash.

public static Messenger readMessengerOrNullFromParcel(Parcel in)

Convenience function for reading either a Messenger or null pointer from a Parcel. You must have previously written the Messenger with writeMessengerOrNullToParcel(Messenger, Parcel).

Parameters

in The Parcel containing the written Messenger.

Returns

  • Returns the Messenger read from the Parcel, or null if null had been written.

public void send(Message message)

Send a Message to this Messenger's Handler.

Parameters

message The Message to send. Usually retrieved through Message.obtain().

Throws

RemoteException Throws DeadObjectException if the target Handler no longer exists.

public static void writeMessengerOrNullToParcel(Messenger messenger, Parcel out)

Convenience function for writing either a Messenger or null pointer to a Parcel. You must use this with readMessengerOrNullFromParcel(Parcel) for later reading it.

Parameters

messenger The Messenger to write, or null.
out Where to write the Messenger.

public void writeToParcel(Parcel out, int flags)

Flatten this object in to a Parcel.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48