From 1f9175b218f70556730b7f27c87296647b2ec219 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Mon, 30 Jan 2012 15:24:19 +0400 Subject: [PATCH 1/1] cancel background tasks on timeout --- src/org/average/whereami/WhereAmI.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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); } }; -- 2.43.0