自学内容网 自学内容网

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

原文地址:https://blog.csdn.net/m0_70748845/article/details/142578239

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!