public static interface AceInternalAbility.AceInternalAbilityHandler
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
onRemoteRequest(int code,
MessageParcel data,
MessageParcel reply,
MessageOption option) |
Called when an internal ability request is received from the local ability.
|
boolean onRemoteRequest(int code,
MessageParcel data,
MessageParcel reply,
MessageOption option)
throws RemoteException
You need to specify the service code and request data of the internal ability. The request data structures vary depending on the request types.
callAbility request, the data type is JSON object
string. Call Parcel.readString() to read the string and parse the JSON object to
obtain the data.subscribeAbilityEvent request, the data type is
IRemoteObject. Call MessageParcel.readRemoteObject() to obtain
the object, and call IRemoteObject.sendRequest(int, MessageParcel, MessageParcel,
MessageOption) provided by the object to report events, which are distinguished by service codes. The
request data needs to be serialized into a JSON object or JSON array string.unsubscribeAbilityEvent request, set the request data to null.Before publishing your JavaScript APIs, ensure that the service codes and request data structures are forward-compatible.
code - Indicates the service code sent from the JavaScript side. Note that the service code must be
forward-compatible.data - Indicates the request data, which is a MessageParcel object sent from the
JavaScript side. Note that the JSON string representation of the object must be forward-compatible.reply - Indicates the response message, which is a MessageParcel object returned
by the local service. Currently, the value can only be a string or null.option - Indicates whether the operation is synchronous or asynchronous.true if the internal ability operation is successful; returns false
otherwise.RemoteException - Throws this exception if an error occurs during remote processing.