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

相关推荐
l13406208235几秒前
Flutter Geocoding 在鸿蒙上的使用指南
flutter·华为·harmonyos
俩毛豆17 分钟前
【毛豆工具集】【UI】【多设备适配】实现与屏幕密度等倍的图片加载
华为·harmonyos
l134062082351 小时前
344.在鸿蒙上使用 animations Flutter 包的指南
flutter·华为·harmonyos
灯前目力虽非昔,犹课蝇头二万言。2 小时前
HarmonyOS笔记12:生命周期
笔记·华为·harmonyos
Random_index3 小时前
#HarmonyOS篇:学习UI规范基本语法&&学习UI范式装填管理V1&&学习UI范式装填管理V2&&学习UI范式渲染控制
harmonyos
前端世界3 小时前
鸿蒙分布式权限管理实战指南:架构原理 + 可运行 Demo
分布式·架构·harmonyos
MatrixData4 小时前
WiFi子系统
车载系统·座舱子系统·wifi系统
前端世界4 小时前
鸿蒙分布式通信安全实践:中间人攻击原理与防御实现
分布式·华为·harmonyos
kirk_wang5 小时前
Flutter 三方库 simple_circular_progress_bar 在 OHOS 平台的适配实践
flutter·移动开发·跨平台·arkts·鸿蒙
13 小时前
鸿蒙——通知
华为·harmonyos·