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

相关推荐
zuowei288919 分钟前
华为网络设备配置文件备份与恢复(上传、下载、导出,导入)
开发语言·华为·php
沙雕不是雕又菜又爱玩1 小时前
ArkUI学习(2)
鸿蒙
C雨后彩虹5 小时前
最多等和不相交连续子序列
java·数据结构·算法·华为·面试
代码飞一会儿5 小时前
Harmony OS开发之沉浸式模式设计学习
harmonyos·敏捷开发
liulian09167 小时前
Flutter 三方库 flutter_local_auth 的鸿蒙化适配指南
flutter·华为·学习方法·harmonyos
SuperHeroWu77 小时前
【鸿蒙基础入门】概念理解和学习方法论说明
前端·学习·华为·开源·harmonyos·鸿蒙·移动端
亘元有量-流量变现8 小时前
抓住鸿蒙流量红利!2026华为应用商店ASO优化全解
华为·harmonyos·aso优化
特立独行的猫a8 小时前
使用 vcpkg 为OpenHarmony(鸿蒙PC)构建 OpenSSH 命令行工具
harmonyos·openharmony·命令行·openssh·vcpkg·鸿蒙pc
音视频牛哥8 小时前
纯血鸿蒙(HarmonyOS NEXT)下,如何实现低延迟RTSP、RTMP播放器音视频解码?
华为·音视频·harmonyos·鸿蒙rtmp播放器·鸿蒙rtsp播放器·harmonyos rtsp·鸿蒙next播放器
特立独行的猫a10 小时前
OpenSSH 介绍及使用Lycium框架移植到鸿蒙 PC(OpenHarmony)平台的实践总结
harmonyos·openssh·鸿蒙pc·lycium_plusplus·三分库移植