Handler.HasCallbacks(IRunnable) Method

Definition

Check if there are any pending posts of messages with callback r in the message queue.

[Android.Runtime.Register("hasCallbacks", "(Ljava/lang/Runnable;)Z", "", ApiSince=29)]
public bool HasCallbacks(Java.Lang.IRunnable r);
[<Android.Runtime.Register("hasCallbacks", "(Ljava/lang/Runnable;)Z", "", ApiSince=29)>]
member this.HasCallbacks : Java.Lang.IRunnable -> bool

Parameters

r
IRunnable

The value cannot be null.

Returns

true if the requested condition is met; otherwise, false.

Attributes

Remarks

Check if there are any pending posts of messages with callback r in the message queue.

This operation is worst case O(n) in the number of messages in the queue, and should be avoided. Instead consider another mechanism outside of the queue to track if messages were enqueued and dispatched. For instance, maintain a counter, incrementing it when enqueuing a message and decrementing it when handling a message.

Java documentation for android.os.Handler.hasCallbacks(java.lang.Runnable).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to