文档管理中心
API参考定位服务Androidcom.huawei.hms.locationClass SummaryGeofenceService

GeofenceService

展开

Class Info

public class GeofenceService

地理围栏,程序定位交互接入类。在调用LocationServices类的getGeofenceService(Activity activity)或getGeofenceService(Context context)方法时返回一个该类型的实例。

Public Method Summary

展开

Qualifier and Type

Method Name and Description

Task<Void>

createGeofenceList(GeofenceRequest geofenceRequest, PendingIntent pendingIntent)

通过传入PendingIntent的方式添加地理围栏,当触发围栏的时候,会通过广播通知。

Task<Void>

deleteGeofenceList(List<String> geofenceRequestIds)

通过地理围栏请求Id移除地理围栏。

Task<Void>

deleteGeofenceList(PendingIntent pendingIntent)

通过添加地理围栏请求时对应的PendingIntent移除地理围栏。

Public Methods

createGeofenceList(GeofenceRequest geofenceRequest, PendingIntent pendingIntent)

展开

Method

public Task<Void> createGeofenceList(GeofenceRequest geofenceRequest, PendingIntent pendingIntent)

通过传入PendingIntent的方式添加地理围栏,当触发围栏的时候,会通过广播通知。

Parameters

展开

Name

Description

geofenceRequest

地理围栏请求对象。

pendingIntent

每个地理围栏请求关联的PendingIntent,构造PendingIntent时需设置Class、Action,不能构造空Intent。

Returns

展开

Type

Description

Task<Void>

任务,可以通过添加onComplete(Task task)回调接受添加结果,如果task.isSuccessful()为true,则代表添加地理围栏成功;否则添加失败。

说明

需要用户App重新下发地理围栏的场景:

  • 用户App卸载后重装。
  • 用户App版本升级。
  • HMS Core删除数据。
  • 手机重启。

deleteGeofenceList(List<String> geofenceRequestIds)

展开

Method

public Task<Void> deleteGeofenceList(List<String> geofenceRequestIds)

通过地理围栏请求ID移除地理围栏。

Parameters

展开

Name

Description

geofenceRequestIds

待移除的地理围栏请求IDs。

Returns

展开

Type

Description

Task<Void>

任务,可以通过添加onComplete(Task task)回调接受移除结果,如果task.isSuccessful()为true,则代表移除地理围栏成功;否则移除失败。

deleteGeofenceList(PendingIntent pendingIntent)

展开

Method

public Task<Void> deleteGeofenceList(PendingIntent pendingIntent)

通过添加地理围栏请求时对应的PendingIntent移除地理围栏。

Parameters

展开

Name

Description

pendingIntent

待移除的地理围栏请求对应的PendingIntent。

Returns

展开

Type

Description

Task<Void>

任务,可以通过添加onComplete(Task task)回调接受移除结果,如果task.isSuccessful()为true,则代表移除地理围栏成功;否则移除失败。

在 API参考 中进行搜索
请输入您想要搜索的关键词