From c668d248ab0d3a815f98fd972f33fd23ca7fca7f Mon Sep 17 00:00:00 2001 From: Georg Lukas Date: Wed, 15 Feb 2012 21:42:07 +0100 Subject: [PATCH] fail properly for SM without GPS support --- res/values/strings.xml | 1 + src/location/SmartBeaconing.scala | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 130d16e..19e74da 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -52,6 +52,7 @@ APRS Service started. Updates every %1$d minutes, %2$d km. APRS Service stopped. You need to enable either GPS or Network Location for APRSdroid to work properly! +SmartBeaconing™ requires GPS! Error received diff --git a/src/location/SmartBeaconing.scala b/src/location/SmartBeaconing.scala index 0a29663..1220388 100644 --- a/src/location/SmartBeaconing.scala +++ b/src/location/SmartBeaconing.scala @@ -17,8 +17,14 @@ class SmartBeaconing(service : AprsService, prefs : PrefsWrapper) extends Locati def start(singleShot : Boolean) = { lastLoc = null stop() - locMan.requestLocationUpdates(PeriodicGPS.bestProvider(locMan), - 0, 0, this) + try { + locMan.requestLocationUpdates(LocationManager.GPS_PROVIDER, + 0, 0, this) + } catch { + case e : IllegalArgumentException => + // this device does not have GPS. Oops. + service.postAbort(service.getString(R.string.service_sm_no_gps)) + } service.getString(R.string.p_source_smart) } @@ -106,7 +112,7 @@ class SmartBeaconing(service : AprsService, prefs : PrefsWrapper) extends Locati Log.d(TAG, "onProviderDisabled: " + provider) if (provider == LocationManager.GPS_PROVIDER) { // GPS was our last data source, we have to complain! - Toast.makeText(service, R.string.service_no_location, Toast.LENGTH_LONG).show() + Toast.makeText(service, R.string.service_sm_no_gps, Toast.LENGTH_LONG).show() } } override def onProviderEnabled(provider : String) {