Sequenceablepublic class GeneralReceiver extends Object implements Sequenceable
You can create a child class instance, override the onReceive(int, ohos.utils.PacMap) method, and send the child class
instance to the peer end through IPC. The peer end then uses sendResult(int, ohos.utils.PacMap) to send the result back.
Sequenceable.Producer<T>| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static Sequenceable.Producer<GeneralReceiver> |
PRODUCER |
Creates a
GeneralReceiver instance from a Parcel. |
| 构造器 | 说明 |
|---|---|
GeneralReceiver() |
A constructor used to create a
GeneralReceiver instance whose
EventHandler is null. |
GeneralReceiver(EventHandler handler) |
A constructor used to create a
GeneralReceiver instance with an
EventHandler object passed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
marshalling(Parcel out) |
Marshals a
GeneralReceiver object into a Parcel. |
protected void |
onReceive(int code,
PacMap data) |
Receives the result.
|
void |
sendResult(int resultCode,
PacMap resultData) |
Sends a result to the current
GeneralReceiver. |
boolean |
unmarshalling(Parcel in) |
Unmarshals a
GeneralReceiver object from a Parcel. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithasFileDescriptorpublic static final Sequenceable.Producer<GeneralReceiver> PRODUCER
GeneralReceiver instance from a Parcel.public GeneralReceiver()
GeneralReceiver instance whose
EventHandler is null.public GeneralReceiver(EventHandler handler)
GeneralReceiver instance with an
EventHandler object passed.handler - Indicates the EventHandler object. If this parameter is not
null, onReceive(int, ohos.utils.PacMap) will be called on the thread of the specified
EventHandler. If this parameter is null,
onReceive(int, ohos.utils.PacMap) can be called on any thread.public void sendResult(int resultCode,
PacMap resultData)
GeneralReceiver.resultCode - Indicates the custom result code you have defined as required.resultData - Indicates the PacMap object containing result data.protected void onReceive(int code,
PacMap data)
You must override this method.
code - Indicates the result code sent by the sender.data - Indicates the PacMap object containing the result data sent by the sender.public boolean marshalling(Parcel out)
GeneralReceiver object into a Parcel.
A process can call the unmarshalling(ohos.utils.Parcel) method to unmarshal a GeneralReceiver object
from a Parcel to implement inter-process communication (IPC).
marshalling 在接口中 Sequenceableout - Indicates the Parcel object for marshalling.true if the marshalling is successful; returns false otherwise.public boolean unmarshalling(Parcel in)
GeneralReceiver object from a Parcel.unmarshalling 在接口中 Sequenceablein - Indicates the Parcel object for unmarshalling.true if the unmarshalling is successful; returns false otherwise.