How to change java timer interval after scheduling it for fixed rate in android?
I have a service that has one timer. I am timer.scheduleAtFixedRate()
calling in a callback method onStart()
. But I need to change the timer interval depending on the value of the variable. I have not found a function for the timer to change its interval. So I decided to cancel the timer and reschedule when this condition is met. But I am checking the condition with the timer itself. So when I tried to cancel the timer in the TimerTask it throws IllegalStateException
. Can anyone give me some solution?
+2
source to share