鸿蒙开发(NEXT/API 12)【硬件(取消注册出行业务事件监听)】车载系统

取消注册出行业务事件监听。

接口说明

接口名 描述
[off] (type: 'smartMobilityEvent', smartMobilityTypes: SmartMobilityType[], callback?: Callback): void 取消注册出行业务事件监听。

开发步骤

  1. 导入Car Kit模块。

    复制代码
    import { smartMobilityCommon } from '@kit.CarKit';
  2. 获取SmartMobilityEventAwareness实例。

    复制代码
    let awareness: smartMobilityCommon.SmartMobilityAwareness = smartMobilityCommon.getSmartMobilityAwareness();
  3. 应用取消注册出行业务事件监听。

    // 业务类型
    let types: smartMobilityCommon.SmartMobilityType[] = [smartMobilityCommon.SmartMobilityType.CAR_HOP];
    // 出行业务事件回调函数
    const callBack = (event: smartMobilityCommon.SmartMobilityEvent) => {
    hilog.info(0x0000, 'Received smart mobility event: ', JSON.stringify(event));
    };
    // 解注册出行业务事件监听 示例1
    // awareness.off('smartMobilityEvent', types);
    // 解注册出行业务事件监听 示例2
    awareness.off('smartMobilityEvent', types, callBack);

相关推荐
前端不太难2 小时前
鸿蒙 App 的“无状态 System”设计
华为·状态模式·harmonyos
里晓山2 小时前
SOME/IP协议(上)
网络·网络协议·tcp/ip·车载系统
UnicornDev4 小时前
【Flutter x HarmonyOS 6】魔方计时APP——计时逻辑实现
flutter·华为·harmonyos·鸿蒙·鸿蒙系统
AlbertZein16 小时前
ImageKnifePro 源码解读:鸿蒙图片加载框架全貌
harmonyos
AlbertZein17 小时前
鸿蒙工程化:build-profile.json5 逐字段解析
harmonyos
前端技术20 小时前
鸿蒙ArkTS 自定义底部导航栏(Tabs+@Builder 极简实现)
harmonyos·鸿蒙
Swift社区21 小时前
为什么“页面跳转”在鸿蒙 PC 上是错误设计?
华为·harmonyos
熬夜敲代码的小N1 天前
鸿蒙PC开发者必备!GitNext深度测评:一站式Git管理工具
git·华为·harmonyos
秋の本名1 天前
第一章 鸿蒙生态架构与开发理念
华为·wpf·harmonyos
Ww.xh1 天前
鸿蒙系统中HTML与Vue集成方案
vue.js·html·harmonyos