From: Keith Packard Date: Fri, 12 Apr 2013 05:16:25 +0000 (-0700) Subject: altosdroid: Hook up the position listeners X-Git-Tag: altosdroid_v1.2-1~23 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=1f88d345c407e409611448d0e8813ab5a6de0a0b altosdroid: Hook up the position listeners Signed-off-by: Keith Packard --- diff --git a/altosdroid/AndroidManifest.xml b/altosdroid/AndroidManifest.xml index 237c6dcf..bf885744 100644 --- a/altosdroid/AndroidManifest.xml +++ b/altosdroid/AndroidManifest.xml @@ -31,7 +31,6 @@ - service; @@ -249,6 +278,14 @@ public class TelemetryService extends Service { // Start our timer - first event in 10 seconds, then every 10 seconds after that. timer.scheduleAtFixedRate(new TimerTask(){ public void run() {onTimerTick();}}, 10000L, 10000L); + // Listen for GPS and Network position updates + gpsListener = new AltosLocationListener(true); + netListener = new AltosLocationListener(false); + + LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); + + locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, gpsListener); + locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, netListener); } @Override @@ -281,6 +318,11 @@ public class TelemetryService extends Service { @Override public void onDestroy() { + // Stop listening for location updates + LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); + locationManager.removeUpdates(gpsListener); + locationManager.removeUpdates(netListener); + // Stop the bluetooth Comms threads stopAltosBluetooth();