目录

说明

  1. 使用室外高精度能力的开发者需要遵守国家法律法规与华为公司共同向国家有关部门申请高精度偏转插件的使用许可。
  2. 室外高精度能力当前仅支持中国大陆地区的部分城市:深圳市、广州市、苏州市、杭州市、重庆市、成都市、天津市、东莞市(持续增加中),海外暂不支持。

Name

Description

Android

基于Java语言开发的独立Android应用程序接口,提供客户端侧定位服务能力。主要包含五个部分能力:融合定位、活动识别、地理围栏、室外高精度、室内定位,您可以根据自己的需求,调用相应的能力。使用室外高精度和室内定位能力需收费,收费标准请参见服务定价。

HarmonyOS(Java)

基于Java语言开发的独立HarmonyOS(Java)应用程序接口,目前支持融合定位。

iOS(Objective-C)

基于Objective-C语言开发的独立iOS应用程序接口,目前支持融合定位。

REST

提供支持HTTPS的云服务接口,用于网络定位(API)和IP定位(API)能力。使用网络定位(API)和IP定位(API)接口需收费,收费标准请参见服务定价。

Android功能支持说明

当您集成HMS Core(APK)时,Location Kit所有功能均支持;当您未集成HMS Core(APK)时,Location Kit仅支持融合定位能力。详情请参见支持的设备。

以下融合定位能力相关接口无论是否依赖HMS Core(APK)均支持调用。

Name

Description

FusedLocationProviderClient接口

public Task<Location> getLastLocation()

返回最后一次请求的可用位置。

public Task<LocationAvailability> getLocationAvailability()

返回位置数据的可用性。

public Task<Void> requestLocationUpdates(LocationRequest request, LocationCallback callback, Looper looper)

请求位置更新,并在指定的Looper线程上回调。

public Task<Void> requestLocationUpdatesEx(LocationRequest request, LocationCallback callback, Looper looper)

扩展的位置信息服务接口,当前支持室外高精度和室内定位,并兼容普通定位接口。

public Task<Void> removeLocationUpdates(LocationCallback callback)

移除指定回调信息的位置更新。

SettingsClient接口

public Task<LocationSettingsResponse> checkLocationSettings(LocationSettingsRequest locationSettingsRequest)

检查位置设置各开关是否可用。

LocationRequest接口

LocationRequest create()

创建LocationRequest。

boolean isFastestIntervalExplicitlySet()

是否使用最快时间间隔。

LocationRequest setCountryCode(String countryCode)

设置国家。

LocationRequest setExpirationDuration(long millis)

请求到期时间段,单位:毫秒。

LocationRequest setExpirationTime(long millis)

请求到期时间,单位:毫秒。

LocationRequest setFastestInterval(long millis)

请求位置回调的最快时间间隔,取Interval和FastestInterval的较小值, 单位:毫秒。如果您确实需要设置fastestInterval,建议设置fastestInterval值远小于Interval,这样才有显著的效果。

LocationRequest setInterval(long millis)

请求位置回调的时间间隔,单位:毫秒。

LocationRequest setLanguage(String language)

设置语言。

LocationRequest setMaxWaitTime(long millis)

设置位置更新的最长等待时间,单位:毫秒。

LocationRequest setNeedAddress(boolean needAddress)

设置是否需要返回地址信息。

LocationRequest setNumUpdates(int numUpdates)

请求位置的回调次数,假如值为3时,则只回调3次结果给客户端。

LocationRequest setPriority(int priority)

设置定位类型。

LocationRequest setSmallestDisplacement(float smallestDisplacement)

位置更新的最小位移,单位:米。