cancel background tasks on timeout
authorEugene Crosser <Eugene.Crosser@ru.ibm.com>
Mon, 30 Jan 2012 11:24:19 +0000 (15:24 +0400)
committerEugene Crosser <Eugene.Crosser@ru.ibm.com>
Mon, 30 Jan 2012 11:24:19 +0000 (15:24 +0400)
src/org/average/whereami/WhereAmI.java

index aa980ecf58a0683dafc057a9dfb33aa94d2b0366..e9c3c0349518c736b390abcf542cced79027b6f3 100644 (file)
@@ -65,6 +65,10 @@ public class WhereAmI extends Activity
             task = new BgUpdate();
             task.execute();
         }
             task = new BgUpdate();
             task.execute();
         }
+
+        public void cancel() {
+            task.cancel(true);
+        }
     }
     private UpdateTarget[] ut;
 
     }
     private UpdateTarget[] ut;
 
@@ -124,14 +128,17 @@ public class WhereAmI extends Activity
         public void run() {
             Log.w("WhereAmI", "resetInfo starting");
             unregisterReceiver(connChanged);
         public void run() {
             Log.w("WhereAmI", "resetInfo starting");
             unregisterReceiver(connChanged);
-            boolean wifion = wifiman.setWifiEnabled(false);
-            Log.w("WhereAmI", "disabling wifi result " + wifion);
             if (runningtasks > 0) {
             if (runningtasks > 0) {
+                for (int i = 0; i < ut.length; i++) {
+                    ut[i].cancel();
+                }
                 Time tm = new Time();
                 tm.setToNow();
                 tvs.setText(R.string.failtry);
                 tvs.append(tm.format(" %d/%m/%Y %H:%M:%S"));
             }
                 Time tm = new Time();
                 tm.setToNow();
                 tvs.setText(R.string.failtry);
                 tvs.append(tm.format(" %d/%m/%Y %H:%M:%S"));
             }
+            boolean wifion = wifiman.setWifiEnabled(false);
+            Log.w("WhereAmI", "disabling wifi result " + wifion);
         }
     };
 
         }
     };