In onCreate, I run a task that repeats every minute. Here is how I do it:
myTimer = new Timer(); int delay = 30000; // delay for 30 sec. int period = 600000; // repeat every 60 sec. doThis = new TimerTask() { public void run() { Log.v("TImer","repeated"); wv.reload(); } }; myTimer.scheduleAtFixedRate(doThis, delay, period);
All this code is in onCreate. So, when the application leaves the screen, I see in logcat that the steel timer works, and will not stop if the application is not destroyed. So, in onPause activity, I call myTimer.cancel(); , but it did not help. I still see updates in logcat, even when the application does not appear on the screen. So how to stop timerTask ?
source share