-
-
Save diamondobama/6ef2601538e3ccb6c627 to your computer and use it in GitHub Desktop.
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.Location; | |
import com.codename1.location.LocationListener; | |
/** | |
* | |
* @author shannah | |
*/ | |
public class BackgroundLocationListener implements LocationListener { | |
@Override | |
public void locationUpdated(Location location) { | |
System.out.println("location updated "+location.getLatitude()+", "+location.getLongitude()); | |
} | |
@Override | |
public void providerStateChanged(int newState) { | |
} | |
} |
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"); | |
// Pro users - uncomment this code to get crash reports sent to you automatically | |
/*Display.getInstance().addEdtErrorHandler(new ActionListener() { | |
public void actionPerformed(ActionEvent evt) { | |
evt.consume(); | |
Log.p("Exception in AppName version " + Display.getInstance().getProperty("AppVersion", "Unknown")); | |
Log.p("OS " + Display.getInstance().getPlatformName()); | |
Log.p("Error " + evt.getSource()); | |
Log.p("Current Form " + Display.getInstance().getCurrent().getName()); | |
Log.e((Throwable)evt.getSource()); | |
Log.sendLog(); | |
} | |
});*/ | |
} | |
public void start() { | |
if(current != null){ | |
current.show(); | |
return; | |
} | |
Form hi = new Form("Hi World"); | |
hi.addComponent(new Label("Hi World")); | |
LocationManager.getLocationManager() | |
.setBackgroundLocationListener(BackgroundLocationListener.class); | |
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