Skip to content

Instantly share code, notes, and snippets.

@codenameone
Forked from shannah/BGLocationTest.java
Last active April 17, 2016 16:22
Show Gist options
  • Save codenameone/b0fa5280bde905a8f0cd to your computer and use it in GitHub Desktop.
Save codenameone/b0fa5280bde905a8f0cd to your computer and use it in GitHub Desktop.
Geofence Example
public void showForm() {
Form hi = new Form("Hi World");
hi.addComponent(new Label("Hi World"));
Location loc = new Location();
loc.setLatitude(51.5033630);
loc.setLongitude(-0.1276250);
Geofence gf = new Geofence("test", loc, 100, 100000);
LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, gf);
hi.show();
}
public class GeofenceListenerImpl implements GeofenceListener {
public void onExit(String id) {
System.out.println("Exited "+id);
}
public void onEntered(String id) {
System.out.println("Entered "+id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment