Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CHLibrarian/67527271aa5b0d3011f0 to your computer and use it in GitHub Desktop.
Save CHLibrarian/67527271aa5b0d3011f0 to your computer and use it in GitHub Desktop.
ContextHub Element Services Geofence Create (Android)
// Creating a geofence with name "Geofence", lat/lng of ChaiOne, tag "geofence-tag", radius 250 meters
GeofenceProxy proxy = new GeofenceProxy();
proxy.createGeofence("Geofence", 29.763638f, -95.461874f, 250, new String[]{"geofence-tag"},
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(), "Created geofence: " + 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