I intend to develop an app that, when setting a particular time, scheduling a task with the timertask to run 50 minutes later and immediately after that 50 minutes, repeat for 50 minutes periods successively. But it happens that after 50 minutes of the scheduled time, the task is not executed. But it turns out that tested with shorter times like 5 minutes, the task executes. Does timertask not accept long times? Here is an example of what my code might be:
public void startTimer() {
//set a new Timer
timer = new Timer();
//initialize the TimerTask's job
initializeTimerTask();
timer.schedule(timerTask, 300000, 300000);
}
public void initializeTimerTask() {
timerTask = new TimerTask() {
public void run() {
//use a handler to run a toast that shows the current timestamp
handler.post(new Runnable() {
public void run() {
showNotification();
}
});
}
};
}