I have this method:
public static Runnable runAtDate(Date date, final TimerCallback callback)
{
Date now = new Date();
long timeTo = date.getTime() - now.getTime();
if (timeTo <= 0)
{
if (callback != null)
callback.onRun();
}
else
{
final Runnable runnable = new Runnable()
{
@Override
public void run()
{
if (callback != null)
callback.onRun();
}
};
handler.postDelayed(runnable, timeTo);
return runnable;
}
return null;
}
This works fine when the date is around a few hours later (1, 2, 3) but around 8 hours this method does not work anymore. And since other timers have not been reliable (delayed and whatnot) I chose to use this, because it always execute right on time - when it works.
My question is, what is the maximum hours that a postDelay can run? Do I have to add a new postDelay every (some hours) adding the difference between (some hours) and the exact date?