harmony 鸿蒙Removing Sticky Common Events (for System Applications Only)
Removing Sticky Common Events (for System Applications Only)
When to Use
Subscribers can receive sticky common events that have been sent. If the events are no longer forwarded, the event publisher needs to remove them. OpenHarmony provides an API for removing sticky common events.
Available APIs
For details, see Common Event
Name | Description |
---|---|
removeStickyCommonEvent(event: string, callback: AsyncCallback<void>): void | Removes a sticky common event. |
How to Develop
Request the ohos.permission.COMMONEVENT_STICKY permission. For details, see Declaring Permissions in the Configuration File.
Import the module.
import commonEventManager from '@ohos.commonEventManager';
import Base from '@ohos.base';
- Call the removeStickyCommonEvent() API to remove the target sticky common event.
NOTE
The sticky common event to be removed must have been released by the application. For details about how to release sticky common events, see Publishing Common Events.
commonEventManager.removeStickyCommonEvent("sticky_event", (err: Base.BusinessError) => { // sticky_event indicates the name of the target sticky common event.
if (err) {
console.error(`Failed to remove sticky common event. Code is ${err.code}, message is ${err.message}`);
return;
}
console.info(`Succeeded in removeing sticky event.`);
});
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Using Explicit Want to Start an Application Component
harmony 鸿蒙Using Implicit Want to Open a Website
harmony 鸿蒙AbilityStage Component Container
harmony 鸿蒙Accessing a DataAbility
harmony 鸿蒙Accessing a DataShareExtensionAbility from the FA Model
harmony 鸿蒙AccessibilityExtensionAbility
harmony 鸿蒙Common action and entities Values
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦