鸿蒙开发(NEXT/API 12)【硬件(取消注册智慧出行连接状态的监听)】车载系统

取消注册智慧出行连接状态的监听。

接口说明

接口名 描述
off (type: 'smartMobilityStatus', smartMobilityTypes: SmartMobilityType\[\], callback?: Callback): void 取消注册智慧出行连接状态的监听。

开发步骤**

  1. 导入Car Kit模块。

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

    复制代码
    let awareness: smartMobilityCommon.SmartMobilityAwareness = smartMobilityCommon.getSmartMobilityAwareness();
  3. 取消注册智慧出行连接状态的监听。

    // 业务类型
    let types: smartMobilityCommon.SmartMobilityType[] = [smartMobilityCommon.SmartMobilityType.CAR_HOP];
    // 出行连接状态回调函数
    const callBack = (info: smartMobilityCommon.SmartMobilityInfo) => {
    hilog.info(0x0000, 'Received smart mobility info: ', JSON.stringify(info));
    };
    // 解注册智慧出行连接状态的监听 示例1
    // awareness.off('smartMobilityStatus', types);
    // 解注册智慧出行连接状态的监听 示例2
    awareness.off('smartMobilityStatus', types, callBack);

相关推荐
m0_749690235 小时前
【寻迹校园 HarmonyOS NEXT 实战 16】Preferences 还是 RelationalStore:HarmonyOS 本地存储选型实战
华为·harmonyos·arkts·preferences·relationalstore
2501_919749038 小时前
华为鸿蒙免费听歌APP—小羊免费听歌
华为·harmonyos·鸿蒙
OH_TPC9 小时前
HarmonyOS APP开发---"祝福圈"节日贺卡App,需要用到这个库
harmonyos
m0_7496902311 小时前
【寻迹校园 HarmonyOS NEXT 实战 31】举报去重怎么做:同一记录的重复投诉不应制造多条处理中案件
harmonyos·arkts·relationalstore·内容治理·举报去重
贾伟康12 小时前
【中国方言题库|11】HarmonyOS ArkTS 学习统计实战:计算地区学习进度与收藏数量
harmonyos·arkts·arkui·数据统计·多设备适配
用户12695508791412 小时前
RK3588 + OpenHarmony 6.1 RKNN2 NPU 验证指南
harmonyos
m0_7496902313 小时前
【寻迹校园 HarmonyOS NEXT 实战 35】先写全页面 Design Spec 再写 ArkUI:一个比赛项目的设计稿门禁实践
harmonyos·响应式设计·设计规范·arkui·ui设计
Magic-ZYJ14 小时前
HarmonyOS 日记类 App 的日期设计:本地自然日、月历与夏令时边界
华为·harmonyos·arkts·arkui·问题排查·移动端开发·独立开发者
贾伟康14 小时前
【中国方言题库|12】HarmonyOS ArkTS 题库列表组件实战:减少多地区页面重复并保证点击反馈
harmonyos·arkts·arkui·组件化·多设备适配