Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CHLibrarian/08b89ebf1a73e2e442fe to your computer and use it in GitHub Desktop.
Save CHLibrarian/08b89ebf1a73e2e442fe to your computer and use it in GitHub Desktop.
ContextHub Element Services Geofence Update (Android)
// Updating a geofence with the name "Geofence 2" and adding the tag "office"
// In order to update a geofence, you need to pass in a valid geofence object
geofence.setName("Geofence 2");
geofence.getTags().add("office");
GeofenceProxy proxy = new GeofenceProxy();
proxy.updateGeofence(geofence.getId(), geofence, new Callback<Geofence> {
@Override
public void onSuccess(Geofence result) {
// If you do not have push properly set up, you need to explicitly call synchronize on LocationService so it will generate events for this geofence
LocationService.getInstance().synchronize();
Toast.makeText(getActivity(), result.getName(), Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Exception e) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment