ResultReceiverpublic class ResultReceiver extends Object implements ParcelableGeneric interface for receiving a callback result from someone. Use this
by creating a subclass and implement {@link #onReceiveResult}, which you can
then pass to others and send through IPC, and receive results they
supply with {@link #send}. |
Fields Summary |
---|
final boolean | mLocal | final Handler | mHandler | com.android.internal.os.IResultReceiver | mReceiver | public static final Parcelable.Creator | CREATOR |
Constructors Summary |
---|
public ResultReceiver(Handler handler)Create a new ResultReceive to receive results. Your
{@link #onReceiveResult} method will be called from the thread running
handler if given, or from an arbitrary thread if null.
mLocal = true;
mHandler = handler;
| ResultReceiver(Parcel in)
mLocal = false;
mHandler = null;
mReceiver = IResultReceiver.Stub.asInterface(in.readStrongBinder());
|
Methods Summary |
---|
public int | describeContents()
return 0;
| protected void | onReceiveResult(int resultCode, Bundle resultData)Override to receive results delivered to this object.
| public void | send(int resultCode, Bundle resultData)Deliver a result to this receiver. Will call {@link #onReceiveResult},
always asynchronously if the receiver has supplied a Handler in which
to dispatch the result.
if (mLocal) {
if (mHandler != null) {
mHandler.post(new MyRunnable(resultCode, resultData));
} else {
onReceiveResult(resultCode, resultData);
}
return;
}
if (mReceiver != null) {
try {
mReceiver.send(resultCode, resultData);
} catch (RemoteException e) {
}
}
| public void | writeToParcel(Parcel out, int flags)
synchronized (this) {
if (mReceiver == null) {
mReceiver = new MyResultReceiver();
}
out.writeStrongBinder(mReceiver.asBinder());
}
|
|