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

相关推荐
前端技术1 小时前
通信网络基础(下篇):TCP/IP网络参考模型与传输层协议深度解析
华为
IntMainJhy5 小时前
Flutter 三方库 ImageCropper 图片裁剪鸿蒙化适配与实战指南(正方形+自定义比例全覆盖)
flutter·华为·harmonyos
IntMainJhy5 小时前
Flutter for OpenHarmony 第三方库六大核心模块整合实战全解|从图片处理、消息通知到加密存储、设备推送 一站式鸿蒙适配开发总结
flutter·华为·harmonyos
key_3_feng5 小时前
HarmonyOS 6.0 元服务(Meta Ability)深度设计方案
pytorch·深度学习·harmonyos·元服务
UnicornDev5 小时前
【HarmonyOS 6】基于API23的底部悬浮导航
华为·harmonyos·arkts·鸿蒙·鸿蒙系统
音视频牛哥5 小时前
鸿蒙 NEXT 时代:如何构建工业级稳定和低延迟的同屏推流模块?
华为·harmonyos·大牛直播sdk·鸿蒙next 无纸化同屏·鸿蒙next同屏推流·鸿蒙rtmp同屏·鸿蒙无纸化会议同屏
IntMainJhy5 小时前
【fluttter for open harmony】Flutter 三方库适配实战:在 OpenHarmony 上实现图片压缩功能(附超详细踩坑记录)
flutter·华为·harmonyos
jiejiejiejie_5 小时前
Flutter for OpenHarmony 多语言国际化超简单实现指南
flutter·华为·harmonyos
2301_814809866 小时前
【HarmonyOS 6.0】ArkWeb 嵌套滚动快速调度策略:从机制到落地的全景解析
华为·harmonyos
前端不太难6 小时前
用 ArkUI 写一个小游戏,体验如何?
状态模式·harmonyos