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

相关推荐
2501_919749034 小时前
华为鸿蒙免费视频播放器APP—小羊免费播放器
华为·harmonyos·鸿蒙
2501_919749035 小时前
华为鸿蒙免费背书背课文背稿子APP—小羊背诵
华为·harmonyos·鸿蒙
OH_TPC6 小时前
HarmonyOS APP开发---"随手画"白板涂鸦App,需要用到这个库
harmonyos
lilian2337 小时前
HarmonyOS 7 新特性(二十六)|LazyLayoutAlgorithm 自定义懒布局
华为·harmonyos
数智化码农7 小时前
企业人才测评系统怎么选|同鑫科技测评系统功能优势解析
车载系统
lilian2338 小时前
HarmonyOS 7 新特性(二十九)|游戏伴随服务:悬浮协作与质量降级
游戏·语音识别·harmonyos
王二蛋与他的张大花8 小时前
让小艺替我回答“还有多久下班“——摸鱼鸭的 HarmonyOS 7 Skill 接入实战
harmonyos
用户0934077735149 小时前
HarmonyOS WPS Open SDK 实践:把水印与修订收成打开策略层
android·typescript·harmonyos
Veer Han11 小时前
DevEco CLI 实战:鸿蒙 App「宝贝日程表」从 0 开发到正式上架
华为·harmonyos
李游Leo11 小时前
【共创稿事节】 HarmonyOS 7 空间化 UI 实战:从平面布局到空间层级的界面重构
ui·平面·harmonyos