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

相关推荐
90后的晨仔20 分钟前
鸿蒙主题切换:一个开关搞定白天/黑夜模式
harmonyos
kirk_wang2 小时前
Flutter三方库在OHOS平台适配实践:wakelock屏幕唤醒管理
flutter·移动开发·跨平台·arkts·鸿蒙
蜀道山QAQ4 小时前
HarmonyOS应用开发:弹窗封装
harmonyos·鸿蒙开发·harmonyos4.0
w139548564226 小时前
Flutter跨平台开发鸿蒙化JS-Dart通信桥接组件使用指南
javascript·flutter·harmonyos
御承扬6 小时前
鸿蒙原生系列之动画效果(关键帧动画)
华为·harmonyos·鸿蒙ndk ui·关键帧动画
Keya7 小时前
DevEco Studio 使用技巧全面解析
前端·前端框架·harmonyos
前端世界8 小时前
HarmonyOS 应用启动太慢?一套实战方案把首屏时间压下来
华为·harmonyos
灰灰勇闯IT9 小时前
鸿蒙 ArkUI 声明式 UI 核心:状态管理(@State/@Prop/@Link)实战解析
人工智能·计算机视觉·harmonyos
方白羽11 小时前
Android和HarmonyOS 设置透明度
android·app·harmonyos
2502_9462043112 小时前
Cordova与OpenHarmony应用设置系统
鸿蒙