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

注册智慧出行连接状态的监听,用于获取业务连接状态的变更。

接口说明

接口名 描述
[on] (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.HICAR];
    // 出行连接状态回调函数
    const callBack = (info: smartMobilityCommon.SmartMobilityInfo) => {
    hilog.info(0x0000, 'Received smart mobility info: ', JSON.stringify(info));
    };
    // 注册智慧出行连接状态的监听
    awareness.on('smartMobilityStatus', types, callBack);

相关推荐
星释3 小时前
鸿蒙Flutter三方库适配指南:09.版本升级适配
flutter·华为·harmonyos
电化学仪器白超15 小时前
④使用 PPTSYNC.exe 与华为手机拍照制作 GIF 动画
服务器·华为·智能手机
CN-cheng15 小时前
Flutter项目在HarmonyOS(鸿蒙)运行报错问题总结
flutter·华为·harmonyos·flutter运行到鸿蒙
碧波bibo16 小时前
在编译OpenHarmony遇到third_party/libnl编译报错的修复办法
鸿蒙
平平不平凡16 小时前
鸿蒙音频播放器深度解析:从核心设计到完整实现
harmonyos
汽车仪器仪表相关领域18 小时前
汽车排放检测的 “模块化核心”:HORIBA OBS-ONE GS Unit 气体分析单元技术解析
大数据·人工智能·功能测试·车载系统·汽车·安全性测试·汽车检测
HMSCore18 小时前
【FAQ】HarmonyOS SDK 闭源开放能力 — Form Kit
harmonyos
小Mei数码说18 小时前
华为WATCH D2 & WATCH GT6:秋季来临,尊爱老人的智能守护
华为
极客范儿18 小时前
华为HCIP网络工程师认证—网络参考模型
网络·华为
摘星编程20 小时前
昇腾NPU性能调优实战:INT8+批处理优化Mistral-7B全记录
人工智能·华为·gitcode·昇腾