From befb2847ea144eebc7e326e827d9b5c1209630f5 Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Mon, 11 Apr 2011 01:15:07 +0200 Subject: [PATCH] allow 'single shot' during tracking --- src/AprsService.scala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/AprsService.scala b/src/AprsService.scala index ba93d92..e55004a 100644 --- a/src/AprsService.scala +++ b/src/AprsService.scala @@ -82,8 +82,6 @@ class AprsService extends Service with LocationListener { } def handleStart(i : Intent) { - running = true - // get update interval and distance val upd_int = prefs.getStringInt("interval", 10) val upd_dist = prefs.getStringInt("distance", 10) @@ -92,12 +90,18 @@ class AprsService extends Service with LocationListener { // but we need this to prevent error message reordering) fastLaneLoc = null if (i.getAction() == SERVICE_ONCE) { - lastLoc = null // for singleshot mode, ignore last post - singleShot = true - showToast(getString(R.string.service_once)) + // if already running, we want to send immediately and continue; + // otherwise, we finish after a single position report + lastLoc = null + // set to true if not yet running or already running singleShot + singleShot = !running || singleShot + if (singleShot) + showToast(getString(R.string.service_once)) } else showToast(getString(R.string.service_start).format(upd_int, upd_dist)) + running = true + // the poster needs to be running before location updates come in startPoster()