openharmony 鸿蒙 changelogs-geoLocationManager

2023-10-30 浏览 (312)

Location Subsystem Changelog

cl.location.1 Addition of APIs for Obtaining the Wi-Fi and Bluetooth Scanning Result

APIs for obtaining the Wi-Fi and Bluetooth scanning result are added to @ohos.geoLocationManager.d.ts. They are all system APIs.

Change Impact

The system application can use the Wi-Fi and Bluetooth scanning result obtained by these APIs for network positioning.

Key API/Component Changes

ClassAPI TypeDeclarationChange Type
geoLocationManagermethodfunction on(type: 'locatingRequiredDataChange', config: LocatingRequiredDataConfig, callback: Callback<Array<LocatingRequiredData>>): void;Added
geoLocationManagermethodfunction off(type: 'locatingRequiredDataChange', callback?: Callback<Array<LocatingRequiredData>>): void;Added
geoLocationManagermethodfunction getLocatingRequiredData(config: LocatingRequiredDataConfig): Promise<Array<LocatingRequiredData>>;Added

Adaptation Guide

The following example shows how to obtain Wi-Fi and Bluetooth scanning information at a time:

import geoLocationManager from '@ohos.geoLocationManager';
let config = {'type': 1, 'needStartScan': true, 'scanInterval': 10000};
try {
    geoLocationManager.getLocatingRequiredData(config).then((result) => {
        console.log('getLocatingRequiredData return: ' + JSON.stringify(result));
    })  
    .catch((error) => {
        console.log('promise, getLocatingRequiredData: error=' + JSON.stringify(error));
    });
} catch (err) {
    console.error("errCode:" + err.code + ",errMessage:" + err.message);
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkUI Subsystem Changelog

harmony 鸿蒙Device Management Changelog

harmony 鸿蒙Input Method Framework Subsystem – Input Method Framework Service Changelog

harmony 鸿蒙Multimedia Subsystem Changelog

harmony 鸿蒙Theme Framework Subsystem – Screen Lock Management Service Changelog

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/833a3303971343839218c3d6c51c8728