harmony 鸿蒙Unsubscribing from Common Events in C
Unsubscribing from Common Events in C
When to Use
After completing service requirements, subscribers need to unsubscribe from common events.
Available APIs
For details about the APIs, see CommonEvent.
API | Description |
---|---|
CommonEvent_ErrCode OH_CommonEvent_UnSubscribe(const CommonEvent_Subscriber* subscriber) | Creates the subscriber information. |
How to Develop
- Reference header files.
#include <cstdint>
#include "hilog/log.h"
#include "BasicServicesKit/oh_commonevent.h"
- Add dynamic link libraries to the CMake script.
target_link_libraries(entry PUBLIC
libace_napi.z.so
libhilog_ndk.z.so
libohcommonevent.so
)
- Unsubscribe from a common event.
After a subscriber subscribes to a common event and meets service requirements, the subscriber can use OH_CommonEvent_UnSubscribe to unsubscribe from the event.
void Unsubscribe(CommonEvent_Subscriber* subscriber) {
// Unsubscribe from a common event by passing a subscriber.
int32_t ret = OH_CommonEvent_UnSubscribe(subscriber);
OH_LOG_Print(LOG_APP, LOG_INFO, 1, "CES_TEST", "OH_CommonEvent_UnSubscribe ret <%{public}d>.", ret);
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Process and Thread Communication
harmony 鸿蒙Introduction to Common Events
harmony 鸿蒙Publishing Common Events
harmony 鸿蒙Removing Sticky Common Events (for System Applications Only)
harmony 鸿蒙Subscribing to Common Events in Static Mode (for System Applications Only)
harmony 鸿蒙Common Event Subscription Overview
harmony 鸿蒙Subscribing to Common Events in Dynamic Mode
harmony 鸿蒙Unsubscribing from Common Events in Dynamic Mode
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦