I am creating an app that vibrate and beep every 30 sec and when I log out the vibrate and beep must be cancelled and when I log in the vibrate and beep should resume.
Why do you need a static TimerTask.You can give like this which works fine for me.
timer.schedule(new TimerTask() { @Override public void run() { //your code } }, 0, 30000);
While logout use, timer.cancel(). Here you can simply cancel the timer.No need to cancel the TimerTask.
timer.cancel().