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

相关推荐
猫林老师16 小时前
HarmonyOS测试与上架:单元测试、UI测试与App Gallery Connect发布实战
ui·单元测试·harmonyos
SWUT胖虎16 小时前
ArkTS 中@Extend 和@Styles 装饰器的用法和区别
harmonyos·arkts·鸿蒙·鸿蒙系统
猫林老师18 小时前
鸿蒙元服务开发:免安装的卡片式服务(Atomic Service)
华为·wpf·harmonyos
shr007_1 天前
flutter 鸿蒙
flutter·华为·harmonyos
鼓掌MVP1 天前
【案例实战】多维度视角:鸿蒙2048游戏开发的深度分析与感悟
华为·ai编程·harmonyos·arkts·游戏开发·ability
安卓开发者1 天前
鸿蒙Next Performance Analysis Kit:打造极致流畅的应用体验
华为·harmonyos
Devil枫1 天前
【案例实战】HarmonyOS应用性能优化实战案例
华为·性能优化·harmonyos
猫林老师1 天前
HarmonyOS线程模型与性能优化实战
数据库·分布式·harmonyos
一路阳光8511 天前
鸿蒙生态发力,鸿蒙智行引领智能产业新征程
华为·harmonyos
一路阳光8511 天前
开源鸿蒙5.0正式发布 底座及配套能力快速稳定成熟
华为·开源·harmonyos