| CLASS info |
| public class GeofenceService |
| 地理围栏,程序定位交互接入类。 |
| Return type | Method name |
| Task<Void> | createGeofenceList(GeofenceRequest geofenceRequest, PendingIntent pendingIntent) |
| Task<Void> | deleteGeofenceList(List<String> geofenceRequestIds) |
| Task<Void> | deleteGeofenceList(PendingIntent pendingIntent) |
| Method |
| public Task<Void> createGeofenceList(GeofenceRequest geofenceRequest, PendingIntent pendingIntent) |
| 通过传入PendingIntent的方式添加地理围栏,当触发围栏的时候,会通过广播通知。 |
Parameters
| Parameter name | Parameter desc |
| geofenceRequest | 地理围栏请求对象。 |
| pendingIntent | 每个地理围栏请求关联的PendingIntent,构造PendingIntent时需设置Class、Action,不能构造空Intent。 |
Return
| type | desc |
| Task<Void> | 任务,可以通过添加onComplete(Task task)回调接受添加结果,如果task.isSuccessful()为true,则代表添加地理围栏成功;否则添加失败。 |
注意事项
需要用户app重新下发围栏的场景:
目前现状:
用户app卸载重装之后
用户app版本升级之后
hms core重启之后
hms core升级之后
hms core删除数据之后
手机重启之后
目标:
用户app卸载重装之后
用户app版本升级之后
hms core删除数据之后
手机重启之后
| Method |
| public Task<Void> deleteGeofenceList(List<String> geofenceRequestIds) |
| 通过地理围栏请求Id移除地理围栏,若list为空则会抛出异常。 |
Parameters
| Parameter name | Parameter desc |
| geofenceRequestIds | 待移除的地理围栏请求IDs。 |
Throws
| Parameter name | Parameter desc |
| NullPointerException | geofenceRequestIds 为null或空列表时抛出。 |
Return
| type | desc |
| Task<Void> | 任务,可以通过添加onComplete(Task task)回调接受移除结果,如果task.isSuccessful()为true,则代表移除地理围栏成功;否则移除失败。 |
| Method |
| public Task<Void> deleteGeofenceList(PendingIntent pendingIntent) |
| 通过添加地理围栏请求时对应的PendingIntent移除地理围栏,若pendingIntent为空则会抛出异常。 |
Parameters
| Parameter name | Parameter desc |
| pendingIntent | 待移除的地理围栏请求对应的PendingIntent。 |
Throws
| Parameter name | Parameter desc |
| NullPointerException | pendingintent 为null时抛出。 |
Return
| type | desc |
| Task<Void> | 任务,可以通过添加onComplete(Task task)回调接受移除结果,如果task.isSuccessful()为true,则代表移除地理围栏成功;否则移除失败。 |