]> www.average.org Git - WhereAmI.git/blobdiff - src/org/average/whereami/LastLocation.java
Stay alive unless closed from menu
[WhereAmI.git] / src / org / average / whereami / LastLocation.java
index c5791160298ab42ece4bf5f4950b100561938a6c..5899bf5b24d1e6f09adb4ea84752d1d1315881ba 100644 (file)
@@ -8,6 +8,8 @@ import org.average.whereami.SayWhen;
 
 import java.lang.Math;
 import java.io.IOException;
+import java.net.UnknownHostException;
+import org.apache.http.conn.HttpHostConnectException;
 
 import com.google.api.client.googleapis.json.GoogleJsonResponseException;
 import com.google.api.client.http.HttpResponseException;
@@ -77,6 +79,16 @@ public final class LastLocation extends Oracle {
                 } catch (HttpResponseException e) {
                        Log.e(TAG, "HttpResponseException: " + e);
                        return new Utterance(false, e.getMessage());
+               } catch (UnknownHostException e) {
+                       Log.e(TAG, "UnknownHostException: " + e);
+                       return new Utterance(false,
+                                       base.connectErrorMessage + "\n" +
+                                       e.getMessage());
+               } catch (HttpHostConnectException e) {
+                       Log.e(TAG, "HttpHostConnectException: " + e);
+                       return new Utterance(false,
+                                       base.connectErrorMessage + "\n" +
+                                       e.getMessage());
                } catch (IOException e) {
                        Log.e(TAG, "IOException: " + e);
                        return new Utterance(false, e.getMessage());
@@ -93,8 +105,9 @@ public final class LastLocation extends Oracle {
                                        Double.parseDouble(loc_lats[i]),
                                        Double.parseDouble(loc_lons[i]));
                        Log.v(TAG, "Dist from " + loc_names[i] +
-                               " is " + dist);
-                       if ((loc_dists[i] == "0") ||
+                               " is " + dist +
+                               ", threshold " + loc_dists[i]);
+                       if ((loc_dists[i].equals("0")) ||
                            (dist < Double.parseDouble(loc_dists[i]))) {
                                locmsg = loc_names[i];
                                break;