In my app I am using a timer and timerTask to perform a certain task repeatedly. the timer is being used in a service. when I run the timer the TimerTask is not called after a certain delay my code is
`
final Timer timer = new Timer();
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
Log.i(TAG, "onStart");
Thread thread = new Thread(this);
thread.start();
try {
Thread.sleep(GlobalClass.time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void run() {
Log.i(TAG, "onStart");
timer.schedule(new TimerTask() {
@Override
public void run() {
Log.i(TAG, "i am in timertask");
try {
setbackground();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}, GlobalClass.time, GlobalClass.time);
}
` GlobalClass.time is a static long variable. please help me.