Sequenceablepublic final class CommonEventSubscribeInfo extends Object implements Sequenceable
After you set the filter criteria in a CommonEventSubscribeInfo object, you can pass it to
the CommonEventManager#subscribeCommonEvent(CommonEventSubscriber) or
CommonEventManager#unsubscribeCommonEvent(CommonEventSubscriber) method to subscribe to or
unsubscribe from common events only from publishers meeting the filter criteria.
For an ordered common event (common event that has a sending order), you can use
the setPriority(int) method to set the subscriber priority, and the ordered common event will be
sent first to a subscriber with a higher priority. Additionally, you can call setThreadMode(ohos.event.commonevent.CommonEventSubscribeInfo.ThreadMode) to
specify the thread to run the callback method. For details, see ThreadMode.
SystemCapability.Notification#CES| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
CommonEventSubscribeInfo.ThreadMode |
Specifies the thread mode so that the callback method of the subscriber runs on the specified thread.
|
Sequenceable.Producer<T>| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static Sequenceable.Producer<CommonEventSubscribeInfo> |
PRODUCER |
Creates a
CommonEventSubscribeInfo instance from a Parcel. |
| 构造器 | 说明 |
|---|---|
CommonEventSubscribeInfo(CommonEventSubscribeInfo subscribeInfo) |
A constructor used to create a
CommonEventSubscribeInfo instance by copying parameters from
an existing one. |
CommonEventSubscribeInfo(MatchingSkills matchingSkills) |
A constructor used to create a
CommonEventSubscribeInfo instance with the
matchingSkills parameters passed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
String |
getDeviceId() |
Obtains the device ID in this
CommonEventSubscribeInfo object. |
MatchingSkills |
getMatchingSkills() |
Obtains the
MatchingSkills object carried in this CommonEventSubscribeInfo object. |
String |
getPermission() |
Obtains the publisher permission of this
CommonEventSubscribeInfo object. |
int |
getPriority() |
Obtains the subscriber priority of this
CommonEventSubscribeInfo object. |
CommonEventSubscribeInfo.ThreadMode |
getThreadMode() |
Obtains the thread mode of this
CommonEventSubscribeInfo object. |
boolean |
marshalling(Parcel out) |
Marshals a
CommonEventSubscribeInfo object into a Parcel. |
void |
setDeviceId(String deviceId) |
Sets the device ID for this
CommonEventSubscribeInfo object. |
void |
setPermission(String permission) |
Sets the permission that the publisher must have in order to send a common event to this subscriber.
|
void |
setPriority(int priority) |
Sets the subscriber priority for this
CommonEventSubscribeInfo object. |
void |
setThreadMode(CommonEventSubscribeInfo.ThreadMode threadMode) |
Sets the thread mode of this
CommonEventSubscribeInfo object. |
String |
toString() |
Returns a string representation of the object.
|
boolean |
unmarshalling(Parcel in) |
Unmarshals a
CommonEventSubscribeInfo object from a Parcel. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waithasFileDescriptorpublic static final Sequenceable.Producer<CommonEventSubscribeInfo> PRODUCER
CommonEventSubscribeInfo instance from a Parcel.public CommonEventSubscribeInfo(MatchingSkills matchingSkills)
CommonEventSubscribeInfo instance with the
matchingSkills parameters passed.matchingSkills - Indicates the MatchingSkills object to be set. This object is used to
match the Intent object carried in a CommonEventData object.public CommonEventSubscribeInfo(CommonEventSubscribeInfo subscribeInfo)
CommonEventSubscribeInfo instance by copying parameters from
an existing one.subscribeInfo - Indicates the CommonEventSubscribeInfo object.public MatchingSkills getMatchingSkills()
MatchingSkills object carried in this CommonEventSubscribeInfo object.MatchingSkills object.public CommonEventSubscribeInfo.ThreadMode getThreadMode()
CommonEventSubscribeInfo object. The thread mode is set
by calling setThreadMode(ohos.event.commonevent.CommonEventSubscribeInfo.ThreadMode).public void setThreadMode(CommonEventSubscribeInfo.ThreadMode threadMode)
CommonEventSubscribeInfo object. The thread mode specifies
the thread to run the callback method for the subscriber.threadMode - Indicates the thread mode to be set, which is specified in ThreadMode.
Currently, only the HANDLER mode is supported.public String getPermission()
CommonEventSubscribeInfo object. The permission is set
by calling setPermission(java.lang.String).public void setPermission(String permission)
permission - Indicates the publisher permission to be set. This parameter is optional. If it is
specified, the value must be a permission that has been defined in the system.CommonEventPublishInfo.setSubscriberPermissions(String[])public void setDeviceId(String deviceId)
CommonEventSubscribeInfo object. Your application will only
receive common events sent from the specified device.deviceId - Indicates the device ID. The value must be an existing device ID on the same ohos network.
Otherwise, it is invalid.public String getDeviceId()
CommonEventSubscribeInfo object. The device ID is set by
calling setDeviceId(java.lang.String).public void setPriority(int priority)
CommonEventSubscribeInfo object.
This method is used only for ordered common events. Subscribers with a higher priority
will receive such events first.priority - Indicates the subscriber priority. The value ranges from -100 to 1000.public int getPriority()
CommonEventSubscribeInfo object.
The priority is set by calling setPriority(int).public boolean marshalling(Parcel out)
CommonEventSubscribeInfo object into a Parcel.
A process can call the unmarshalling(ohos.utils.Parcel) method to unmarshal
a CommonEventSubscribeInfo 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)
CommonEventSubscribeInfo object from a Parcel.unmarshalling 在接口中 Sequenceablein - Indicates the Parcel object for unmarshalling.true if the unmarshalling is successful; returns false otherwise.public String toString()
ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())