Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save romancanoniero/cc5a4b5c638babd01d2800779833a4dc to your computer and use it in GitHub Desktop.

Select an option

Save romancanoniero/cc5a4b5c638babd01d2800779833a4dc to your computer and use it in GitHub Desktop.
Sample usage of the Codename One geofence API to track location
public class GeofenceListenerImpl implements GeofenceListener {
@Override
public void onExit(String id) {
}
@Override
public void onEntered(String id) {
if(Display.getInstance().isMinimized()) {
Display.getInstance().callSerially(() -> {
Dialog.show("Welcome", "Thanks for arriving", "OK", null);
});
} else {
LocalNotification ln = new LocalNotification();
ln.setId("LnMessage");
ln.setAlertTitle("Welcome");
ln.setAlertBody("Thanks for arriving!");
Display.getInstance().scheduleLocalNotification(ln, 10, LocalNotification.REPEAT_NONE);
}
}
}
Geofence gf = new Geofence("test", loc, 100, 100000);
LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, gf);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment