鸿蒙开发(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);

相关推荐
大雷神43 分钟前
HarmonyOS智慧农业管理应用开发教程--高高种地--第32篇:应用测试、优化与调试
华为·harmonyos
前端不太难1 小时前
HarmonyOS 游戏中,被“允许”的异常
游戏·状态模式·harmonyos
木斯佳1 小时前
HarmonyOS 6实战(源码教学篇)— MindSpore Lite Kit 【从证件照工具到端侧图像分割技术全解析】
华为·harmonyos
三声三视1 小时前
HarmonyOS 路由框架 HMRouter 全解析:从原理到实践
华为·harmonyos
王码码20352 小时前
Flutter for OpenHarmony 实战之基础组件:第十七篇 滚动进阶 ScrollController 与 Scrollbar
flutter·harmonyos
小哥Mark2 小时前
Flutter开发鸿蒙年味 + 实用实战应用|春节祝福:列表选卡 + 贴纸拖动 + 截图分享
flutter·harmonyos·鸿蒙
王码码20352 小时前
Flutter for OpenHarmony 实战之基础组件:第十六篇 约束布局 ConstrainedBox 与 AspectRatio
flutter·harmonyos
2501_921930833 小时前
基础入门 React Native 鸿蒙跨平台开发:Video 全屏播放与画中画 鸿蒙实战
react native·react.js·harmonyos
果粒蹬i3 小时前
【HarmonyOS】鸿蒙React Native 实战:打造流畅的底部导航
react native·华为·harmonyos
2501_921930833 小时前
基础入门 React Native 鸿蒙跨平台开发:react-native-switch 开关适配
react native·react.js·harmonyos