I dont know whats wrong going on... I am not able to start a timer in my service. Following the code
public class BkgService extends Service{
private Timer Ser
From the Javadoc for Timer.cancel()
:
Once a timer has been terminated, its execution thread terminates gracefully, and no more tasks may be scheduled on it.
From the Javadoc for Timer.scheduleAtFixedRate()
:
Throws: IllegalStateException - if task was already scheduled or cancelled, timer was cancelled, or timer thread terminated.
The Timer
is cancelled immediately: you need to create a new instance:
private void StartServUpdateTask() {
if(ServUpdTimer != null)
{
ServUpdTimer.cancel();
}
ServUpdTimer = new Timer();
...
}