目录

GeofenceService

Class Info

public class GeofenceService

Geofence location class, which is used for interaction during location. An instance of this class will be returned when the getGeofenceService(Activity activity) or getGeofenceService(Context context) method in the LocationServices class is called.

Public Method Summary

Qualifier and Type

Method Name and Description

Task<Void>

createGeofenceList(GeofenceRequest geofenceRequest, PendingIntent pendingIntent)

Adds geofences through PendingIntent. When a geofence is triggered, a notification will be broadcasted.

Task<Void>

deleteGeofenceList(List<String> geofenceRequestIds)

Deletes geofences based on their creation request IDs.

Task<Void>

deleteGeofenceList(PendingIntent pendingIntent)

Deletes geofences through PendingIntents passed for creating these geofences.

Public Methods

[h2]createGeofenceList(GeofenceRequest geofenceRequest, PendingIntent pendingIntent)

Method

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

Adds geofences through PendingIntent. When a geofence is triggered, a notification will be broadcasted.

Parameters

Name

Description

geofenceRequest

Geofence request object.

pendingIntent

PendingIntent associated with each geofence request. When building a PendingIntent object, you need to set Class and Action. Do not build an empty intent.

Returns

Type

Description

Task<Void>

Task execution result. You can add the onComplete(Task task) callback to receive the adding result. If task.isSuccessful() returns true, the geofences are added successfully. Otherwise, the geofences fail to be added.

Your app needs to redeliver the geofence in scenarios listed below:

  • Your app is uninstalled and then installed again.
  • Your app is updated.
  • HMS Core (APK) deletes relevant data.
  • The user device is restarted.

[h2]deleteGeofenceList(List<String> geofenceRequestIds)

Method

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

Deletes geofences based on their request IDs.

Parameters

Name

Description

geofenceRequestIds

Request IDs of geofences to be removed.

Returns

Type

Description

Task<Void>

Task execution result. You can add the onComplete(Task task) callback to receive the removal result. If task.isSuccessful() returns true, the geofences are removed successfully. Otherwise, the geofences fail to be removed.

[h2]deleteGeofenceList(PendingIntent pendingIntent)

Method

public Task<Void> deleteGeofenceList(PendingIntent pendingIntent)

Deletes geofences through PendingIntents passed for creating these geofences.

Parameters

Name

Description

pendingIntent

PendingIntent associated with geofences to be removed.

Returns

Type

Description

Task<Void>

Task execution result. You can add the onComplete(Task task) callback to receive the removal result. If task.isSuccessful() returns true, the geofences are removed successfully. Otherwise, the geofences fail to be removed.