ohos.common_event_data

Note:

Currently in the beta phase.

This module describes the data of common events.

Import Module

import kit.BasicServicesKit.*

Usage Instructions

API sample code usage instructions:

  • If the first line of sample code contains a "// index.cj" comment, it indicates that the sample can be compiled and run in the "index.cj" file of the Cangjie template project.
  • If the sample requires obtaining the Context application context, it needs to be configured in the "main_ability.cj" file of the Cangjie template project.

For details about the above sample project and configuration template, see Cangjie Sample Code Instructions.

class CommonEventData

public class CommonEventData {
    public var event: String
    public var bundleName: String
    public var code: Int32
    public var data: String
    public var parameters: HashMap<String, ValueType>
}

Function: Data of common events.

System Capability: SystemCapability.Notification.CommonEvent

Since: 22

var bundleName

public var bundleName: String

Function: Indicates the package name, which is empty by default.

Type: String

Read/Write Attribute: Readable and writable

System Capability: SystemCapability.Notification.CommonEvent

Since: 22

var code

public var code: Int32

Function: Indicates the common event data (Int32 type) received by the subscriber. The value of this field is consistent with the data passed through the code field in CommonEventPublishData when the publisher uses commonEventManager.publish to publish the common event. The default value is 0.

Type: Int32

Read/Write Attribute: Readable and writable

System Capability: SystemCapability.Notification.CommonEvent

Since: 22

var data

public var data: String

Function: Indicates the common event data (string type) received by the subscriber. The value of this field is consistent with the data passed through the data field in CommonEventPublishData when the publisher uses commonEventManager.publish to publish the common event.

Type: String

Read/Write Attribute: Readable and writable

System Capability: SystemCapability.Notification.CommonEvent

Since: 22

var event

public var event: String

Function: Indicates the name of the currently received common event.

Type: String

Read/Write Attribute: Readable and writable

System Capability: SystemCapability.Notification.CommonEvent

Since: 22

var parameters

public var parameters: HashMap<String, ValueType>

Function: Indicates the additional information of the common event received by the subscriber. The value of this field is consistent with the data passed through the parameters field in CommonEventPublishData when the publisher uses commonEventManager.publish to publish the common event.

Type: HashMap<String, ValueType>

Read/Write Attribute: Readable and writable

System Capability: SystemCapability.Notification.CommonEvent

Since: 22