android.os
public
final
class
android.os.Messenger
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
Public Constructors
Public Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
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.
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.
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.