Last active
June 4, 2021 15:06
-
-
Save codenameone/3de90e0ff4886ec145e8 to your computer and use it in GitHub Desktop.
Sample usage of the Codename One geofence API to track location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Geofence gf = new Geofence("test", loc, 100, 100000); | |
LocationManager.getLocationManager().addGeoFencing(GeofenceListenerImpl.class, gf); |
Hi! i think that its a problem here: when you create more than one localnotification, the id received when you select the notification is allways the last that you send
This sample is no longer applicable and was forked here: https://gist.github.com/shannah/a5592313da97e085822120af16518874
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample usage of the Geofence & LocalNotification API's.
From the Codename One project