For now, I suggest you put it all in one class, while you get the basic code working, then think about re-structuring it later.
Code:
// this isn't compete code, just the basic elements...
public class MyLocationMIDlet extends MIDlet implements CommandListener, ProximityListener {
private static final float CLOSE_ENOUGH = 50.0; // 50 metres
private Display display = Display.getDisplay(this);
private LocationProvider gps;
public void startApp() {
// must set something here
display.setCurrent(someDisplayable);
}
public void commandAction(Command c, Displayable d) {
// need to initialize these from somewhere...
gps = getLocationProvider();
Coordinates target = getTargetCoordinates();
// now... ask for events when we get close to the target
gps.addProximityListener(this, target, CLOSE_ENOUGH);
// and go to background
display.setCurrent(null);
}
// you need to provide these two, to implement ProximityListened
// this gets called by the LocationProvider when we get close enough to one of the targets we've registered
public void proximityEvent(Coordinates coordinates, Location location) {
// move app to foreground
display.setCurrent(display.getCurrent());
}
public void monitoringStateChanged(boolean isMonitoringActive) {
// do something
}
}
Don't try to run this... I've left a lot of code out for you to add... such as creating the initial screens, attaching Commands to the screens, checking which Command has been activated in the commandAction() method, obtaining the LocationProvider instance, and so on.
Do take a look in the wiki, where you will find lots of example source code.
Graham.