Created
January 14, 2016 20:34
-
-
Save shannah/396cf6083785327adb62 to your computer and use it in GitHub Desktop.
Geofence Example
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
package com.codename1.tests.bglocation; | |
import com.codename1.location.Geofence; | |
import com.codename1.location.Location; | |
import com.codename1.location.LocationManager; | |
import com.codename1.ui.Display; | |
import com.codename1.ui.Form; | |
import com.codename1.ui.Label; | |
import com.codename1.ui.plaf.UIManager; | |
import com.codename1.ui.util.Resources; | |
import java.io.IOException; | |
public class BGLocationTest { | |
private Form current; | |
private Resources theme; | |
public void init(Object context) { | |
theme = UIManager.initFirstTheme("/theme"); | |
} | |
public void start() { | |
if(current != null){ | |
current.show(); | |
return; | |
} | |
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 void stop() { | |
current = Display.getInstance().getCurrent(); | |
} | |
public void destroy() { | |
} | |
} |
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
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package com.codename1.tests.bglocation; | |
import com.codename1.location.GeofenceListener; | |
/** | |
* | |
* @author shannah | |
*/ | |
public class GeofenceListenerImpl implements GeofenceListener { | |
@Override | |
public void onExit(String id) { | |
System.out.println("Exited "+id); | |
} | |
@Override | |
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