From: Eugene Crosser Date: Mon, 30 Jan 2012 11:24:19 +0000 (+0400) Subject: cancel background tasks on timeout X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=1f9175b218f70556730b7f27c87296647b2ec219;p=WhereAmI.git cancel background tasks on timeout --- diff --git a/src/org/average/whereami/WhereAmI.java b/src/org/average/whereami/WhereAmI.java index aa980ec..e9c3c03 100644 --- a/src/org/average/whereami/WhereAmI.java +++ b/src/org/average/whereami/WhereAmI.java @@ -65,6 +65,10 @@ public class WhereAmI extends Activity task = new BgUpdate(); task.execute(); } + + public void cancel() { + task.cancel(true); + } } private UpdateTarget[] ut; @@ -124,14 +128,17 @@ public class WhereAmI extends Activity 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) { + 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")); } + boolean wifion = wifiman.setWifiEnabled(false); + Log.w("WhereAmI", "disabling wifi result " + wifion); } };