Date: 2017jan18
OS: Android
Keywords: example
Q. How can I use sendMessageAtTime() with epoch time?
A. sendMessageAtTime() expects uptimeMillis so you need to convert your time.
boolean sendMessageAtEpochTime(Handler handler, final Message msg, final long epochTime) {
final long diff = epochTime - System.currentTimeMillis();
final long when = SystemClock.uptimeMillis() + diff;
return handler.sendMessageAtTime(msg, when);
}
You can also use
return handler.sendMessageDelayed();
But I see in the Android source that it just calls sendMessageAtTime();