Handler Handler Class

Definition

A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue.

[Android.Runtime.Register("android/os/Handler", ApiSince=1, DoNotGenerateAcw=true)]
public class Handler : Java.Lang.Object
type Handler = class
    inherit Object
Inheritance
HandlerHandler
Derived
Attributes

Remarks

Android platform documentation

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.

Constructors

Handler() Handler()

Default constructor associates this handler with the Looper for the current thread.

Handler(Action<Message>) Handler(Action<Message>)
Handler(Handler+ICallback) Handler(Handler+ICallback)

Constructor associates this handler with the Looper for the current thread and takes a callback interface in which you can handle messages.

Handler(IntPtr, JniHandleOwnership) Handler(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

Handler(Looper) Handler(Looper)

Use the provided Looper instead of the default one.

Handler(Looper, Handler+ICallback) Handler(Looper, Handler+ICallback)

Use the provided Looper instead of the default one and take a callback interface in which to handle messages.

Properties

Class Class

Returns the unique instance of Class that represents this object's class.

(Inherited from Object)
Handle Handle

The handle to the underlying Android instance.

(Inherited from Object)
IJavaObjectEx.IsProxy IJavaObjectEx.IsProxy Inherited from Object
IJavaObjectEx.KeyHandle IJavaObjectEx.KeyHandle Inherited from Object
IJavaObjectEx.NeedsActivation IJavaObjectEx.NeedsActivation Inherited from Object
IJavaPeerable.JniManagedPeerState IJavaPeerable.JniManagedPeerState Inherited from Object
JniIdentityHashCode JniIdentityHashCode Inherited from Object
JniPeerMembers JniPeerMembers
Looper Looper
PeerReference PeerReference Inherited from Object
ThresholdClass ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

Clone() Clone()

Creates and returns a copy of this Object.

(Inherited from Object)
DispatchMessage(Message) DispatchMessage(Message)

Handle system messages here.

Dispose() Dispose() Inherited from Object
Dispose(Boolean) Dispose(Boolean) Inherited from Object
Dump(IPrinter, String) Dump(IPrinter, String)
DumpAsync(IPrinter, String) DumpAsync(IPrinter, String)
Equals(Object) Equals(Object)

Compares this instance with the specified object and indicates if they are equal.

(Inherited from Object)
GetHashCode() GetHashCode()

Returns an integer hash code for this object.

(Inherited from Object)
GetMessageName(Message) GetMessageName(Message)

Returns a string representing the name of the specified message.

HandleMessage(Message) HandleMessage(Message)

Subclasses must implement this to receive messages.

HasMessages(Int32) HasMessages(Int32)

Check if there are any pending posts of messages with code 'what' in the message queue.

HasMessages(Int32, Object) HasMessages(Int32, Object)

Check if there are any pending posts of messages with code 'what' and whose obj is 'object' in the message queue.

JavaFinalize() JavaFinalize()

Invoked when the garbage collector has detected that this instance is no longer reachable.

(Inherited from Object)
Notify() Notify()

Causes a thread which is waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
NotifyAll() NotifyAll()

Causes all threads which are waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
ObtainMessage() ObtainMessage()

Returns a new Message from the global message pool.

ObtainMessage(Int32) ObtainMessage(Int32)

Same as ObtainMessage(), except that it also sets the what member of the returned Message.

ObtainMessage(Int32, Int32, Int32) ObtainMessage(Int32, Int32, Int32)

Same as ObtainMessage(), except that it also sets the what, arg1 and arg2 members of the returned Message.

ObtainMessage(Int32, Int32, Int32, Object) ObtainMessage(Int32, Int32, Int32, Object)

Same as ObtainMessage(), except that it also sets the what, obj, arg1,and arg2 values on the returned Message.

ObtainMessage(Int32, Object) ObtainMessage(Int32, Object)

Same as ObtainMessage(), except that it also sets the what and obj members of the returned Message.

Post(Action) Post(Action)
Post(IRunnable) Post(IRunnable)

Causes the Runnable r to be added to the message queue.

PostAtFrontOfQueue(Action) PostAtFrontOfQueue(Action)
PostAtFrontOfQueue(IRunnable) PostAtFrontOfQueue(IRunnable)

Posts a message to an object that implements Runnable.

PostAtTime(Action, Int64) PostAtTime(Action, Int64)
PostAtTime(Action, Object, Int64) PostAtTime(Action, Object, Int64)
PostAtTime(IRunnable, Int64) PostAtTime(IRunnable, Int64)

uptimeMillis

PostAtTime(IRunnable, Object, Int64) PostAtTime(IRunnable, Object, Int64)

uptimeMillis

PostDelayed(Action, Int64) PostDelayed(Action, Int64)
PostDelayed(IRunnable, Int64) PostDelayed(IRunnable, Int64)

Causes the Runnable r to be added to the message queue, to be run after the specified amount of time elapses.

RemoveCallbacks(Action) RemoveCallbacks(Action)
RemoveCallbacks(Action, Object) RemoveCallbacks(Action, Object)
RemoveCallbacks(IRunnable) RemoveCallbacks(IRunnable)

Remove any pending posts of Runnable r that are in the message queue.

RemoveCallbacks(IRunnable, Object) RemoveCallbacks(IRunnable, Object)

Remove any pending posts of Runnable r with Object token that are in the message queue.

RemoveCallbacksAndMessages(Object) RemoveCallbacksAndMessages(Object)

Remove any pending posts of callbacks and sent messages whose obj is token.

RemoveMessages(Int32) RemoveMessages(Int32)

Remove any pending posts of messages with code 'what' that are in the message queue.

RemoveMessages(Int32, Object) RemoveMessages(Int32, Object)

Remove any pending posts of messages with code 'what' and whose obj is 'object' that are in the message queue.

SendEmptyMessage(Int32) SendEmptyMessage(Int32)

Sends a Message containing only the what value.

SendEmptyMessageAtTime(Int32, Int64) SendEmptyMessageAtTime(Int32, Int64)

Sends a Message containing only the what value, to be delivered at a specific time.

SendEmptyMessageDelayed(Int32, Int64) SendEmptyMessageDelayed(Int32, Int64)

Sends a Message containing only the what value, to be delivered after the specified amount of time elapses.

SendMessage(Message) SendMessage(Message)

Pushes a message onto the end of the message queue after all pending messages before the current time.

SendMessageAtFrontOfQueue(Message) SendMessageAtFrontOfQueue(Message)

Enqueue a message at the front of the message queue, to be processed on the next iteration of the message loop.

SendMessageAtTime(Message, Int64) SendMessageAtTime(Message, Int64)

uptimeMillis

SendMessageDelayed(Message, Int64) SendMessageDelayed(Message, Int64)

Enqueue a message into the message queue after all pending messages before (current time + delayMillis).

SetHandle(IntPtr, JniHandleOwnership) SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
ToArray<T>() ToArray<T>() Inherited from Object
ToString() ToString()

Returns a string containing a concise, human-readable description of this object.

(Inherited from Object)
UnregisterFromRuntime() UnregisterFromRuntime() Inherited from Object
Wait() Wait()

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.

(Inherited from Object)
Wait(Int64) Wait(Int64)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Wait(Int64, Int32) Wait(Int64, Int32)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)

Explicit Interface Implementations

IJavaObjectEx.ToLocalJniHandle() IJavaObjectEx.ToLocalJniHandle() Inherited from Object
IJavaPeerable.Disposed() IJavaPeerable.Disposed() Inherited from Object
IJavaPeerable.DisposeUnlessReferenced() IJavaPeerable.DisposeUnlessReferenced() Inherited from Object
IJavaPeerable.Finalized() IJavaPeerable.Finalized() Inherited from Object
IJavaPeerable.SetJniIdentityHashCode(Int32) IJavaPeerable.SetJniIdentityHashCode(Int32) Inherited from Object
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) Inherited from Object
IJavaPeerable.SetPeerReference(JniObjectReference) IJavaPeerable.SetPeerReference(JniObjectReference) Inherited from Object

Extension Methods

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable) GetJniTypeName(IJavaPeerable)

Applies to