看了源码,token对象最终传递给Message:
public final boolean postAtTime(Runnable r, Object token, long uptimeMillis)
308 {
309 return sendMessageAtTime(getPostMessage(r, token), uptimeMillis);
310 }
private static Message getPostMessage(Runnable r, Object token) {
608 Message m = Message.obtain();
609 m.obj = token;
和 postDelay
public final boolean postDelayed(Runnable r, long delayMillis)
330 {
331 return sendMessageDelayed(getPostMessage(r), delayMillis);
332 }
如果你想要的是
public final boolean postDelayed (Runnable r, Object token, long delay)
那为什么不直接使用
public final boolean postAtTime (Runnable r, Object token, long uptimeMillis)
因为它是一样的。
更新,忘了添加这个:
public final boolean sendMessageDelayed(Message msg, long delayMillis)
442 {
443 if (delayMillis < 0) {
444 delayMillis = 0;
445 }
446 return sendMessageAtTime(msg, SystemClock.uptimeMillis() + delayMillis);
447 }