I mis-read the docs and thought we needed two listeners, one for GPS
and one for network position. Looks like we don't
Signed-off-by: Keith Packard <keithp@keithp.com>
class AltosLocationListener implements LocationListener {
TelemetryService service;
class AltosLocationListener implements LocationListener {
TelemetryService service;
public void onLocationChanged(Location location) {
service.sendLocation(location);
public void onLocationChanged(Location location) {
service.sendLocation(location);
public void onProviderDisabled(String provider) {
}
public void onProviderDisabled(String provider) {
}
- public AltosLocationListener(TelemetryService service, boolean fine) {
- this.fine = fine;
+ public AltosLocationListener(TelemetryService service) {
this.service = service;
}
}
this.service = service;
}
}
- private AltosLocationListener gpsListener;
- private AltosLocationListener netListener;
+ private AltosLocationListener locationListener;
// Last data seen; send to UI when it starts
// Last data seen; send to UI when it starts
timer.scheduleAtFixedRate(new TimerTask(){ public void run() {onTimerTick();}}, 10000L, 10000L);
// Listen for GPS and Network position updates
timer.scheduleAtFixedRate(new TimerTask(){ public void run() {onTimerTick();}}, 10000L, 10000L);
// Listen for GPS and Network position updates
- gpsListener = new AltosLocationListener(this, true);
- netListener = new AltosLocationListener(this, false);
+ locationListener = new AltosLocationListener(this);
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsListener);
- locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, netListener);
+ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
+ locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
// Stop listening for location updates
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
// Stop listening for location updates
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
- locationManager.removeUpdates(gpsListener);
- locationManager.removeUpdates(netListener);
+ locationManager.removeUpdates(locationListener);
// Stop the bluetooth Comms threads
stopAltosBluetooth();
// Stop the bluetooth Comms threads
stopAltosBluetooth();