summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorJake Wharton <jakew@google.com>2018-01-03 21:32:49 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2018-01-03 21:32:49 +0000
commitd5909bd26e7cbf60e5bf69a7fffd01edb2d68c8b (patch)
treefde09c9e562a1184ffdef0dfa74e780f251cb36a /core/java/android
parent5459651bf6cd645e4595363f649f1140b1f1a38a (diff)
parent820e3dd74a4a1db0784cf03c553090c31b111638 (diff)
Merge "Add overload to postDelayed which accepts a token."
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/os/Handler.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/java/android/os/Handler.java b/core/java/android/os/Handler.java
index 3ca1005b8c98..5c5e351d2eeb 100644
--- a/core/java/android/os/Handler.java
+++ b/core/java/android/os/Handler.java
@@ -388,6 +388,8 @@ public class Handler {
* The runnable will be run on the thread to which this handler is attached.
*
* @param r The Runnable that will be executed.
+ * @param token An instance which can be used to cancel {@code r} via
+ * {@link #removeCallbacksAndMessages}.
* @param uptimeMillis The absolute time at which the callback should run,
* using the {@link android.os.SystemClock#uptimeMillis} time-base.
*
@@ -430,6 +432,32 @@ public class Handler {
}
/**
+ * Causes the Runnable r to be added to the message queue, to be run
+ * after the specified amount of time elapses.
+ * The runnable will be run on the thread to which this handler
+ * is attached.
+ * <b>The time-base is {@link android.os.SystemClock#uptimeMillis}.</b>
+ * Time spent in deep sleep will add an additional delay to execution.
+ *
+ * @param r The Runnable that will be executed.
+ * @param token An instance which can be used to cancel {@code r} via
+ * {@link #removeCallbacksAndMessages}.
+ * @param delayMillis The delay (in milliseconds) until the Runnable
+ * will be executed.
+ *
+ * @return Returns true if the Runnable was successfully placed in to the
+ * message queue. Returns false on failure, usually because the
+ * looper processing the message queue is exiting. Note that a
+ * result of true does not mean the Runnable will be processed --
+ * if the looper is quit before the delivery time of the message
+ * occurs then the message will be dropped.
+ */
+ public final boolean postDelayed(Runnable r, Object token, long delayMillis)
+ {
+ return sendMessageDelayed(getPostMessage(r, token), delayMillis);
+ }
+
+ /**
* Posts a message to an object that implements Runnable.
* Causes the Runnable r to executed on the next iteration through the
* message queue. The runnable will be run on the thread to which this