Sdílet prostřednictvím


Handler Constructors

Definition

Overloads

Handler()

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

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(Looper)

Use the provided Looper instead of the default one.

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

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

Handler(IntPtr, JniHandleOwnership)

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

Handler()

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

[Android.Runtime.Register(".ctor", "()V", "")]
public Handler ();
Attributes

Remarks

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

If this thread does not have a looper, this handler won't be able to receive messages so an exception is thrown.

This member is deprecated. Implicitly choosing a Looper during Handler construction can lead to bugs where operations are silently lost (if the Handler is not expecting new tasks and quits), crashes (if a handler is sometimes created on a thread without a Looper active), or race conditions, where the thread a handler is associated with is not what the author anticipated. Instead, use an java.util.concurrent.Executor or specify the Looper explicitly, using Looper#getMainLooper, {link android.view.View#getHandler}, or similar. If the implicit thread local behavior is required for compatibility, use new Handler(Looper.myLooper()) to make it clear to readers.

Java documentation for android.os.Handler.Handler().

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

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.

[Android.Runtime.Register(".ctor", "(Landroid/os/Handler$Callback;)V", "")]
public Handler (Android.OS.Handler.ICallback? callback);
[<Android.Runtime.Register(".ctor", "(Landroid/os/Handler$Callback;)V", "")>]
new Android.OS.Handler : Android.OS.Handler.ICallback -> Android.OS.Handler

Parameters

Attributes

Remarks

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

Handler(Looper)

Use the provided Looper instead of the default one.

[Android.Runtime.Register(".ctor", "(Landroid/os/Looper;)V", "")]
public Handler (Android.OS.Looper looper);
[<Android.Runtime.Register(".ctor", "(Landroid/os/Looper;)V", "")>]
new Android.OS.Handler : Android.OS.Looper -> Android.OS.Handler

Parameters

looper
Looper

The looper, must not be null.

Attributes

Remarks

Use the provided Looper instead of the default one.

Java documentation for android.os.Handler.Handler(android.os.Looper).

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

Handler(Action<Message>)

public Handler (Action<Android.OS.Message> handler);
new Android.OS.Handler : Action<Android.OS.Message> -> Android.OS.Handler

Parameters

handler
Action<Message>

Remarks

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

Handler(Looper, Handler+ICallback)

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

[Android.Runtime.Register(".ctor", "(Landroid/os/Looper;Landroid/os/Handler$Callback;)V", "")]
public Handler (Android.OS.Looper looper, Android.OS.Handler.ICallback? callback);
[<Android.Runtime.Register(".ctor", "(Landroid/os/Looper;Landroid/os/Handler$Callback;)V", "")>]
new Android.OS.Handler : Android.OS.Looper * Android.OS.Handler.ICallback -> Android.OS.Handler

Parameters

looper
Looper
Attributes

Remarks

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

Handler(IntPtr, JniHandleOwnership)

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

protected Handler (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Android.OS.Handler : nativeint * Android.Runtime.JniHandleOwnership -> Android.OS.Handler

Parameters

javaReference
IntPtr

nativeint

A IntPtrcontaining a Java Native Interface (JNI) object reference.

transfer
JniHandleOwnership

A JniHandleOwnershipindicating how to handle javaReference

Remarks

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