Sdílet prostřednictvím


Looper Class

Definition

Class used to run a message loop for a thread.

[Android.Runtime.Register("android/os/Looper", DoNotGenerateAcw=true)]
public class Looper : Java.Lang.Object
[<Android.Runtime.Register("android/os/Looper", DoNotGenerateAcw=true)>]
type Looper = class
    inherit Object
Inheritance
Looper
Attributes

Remarks

Class used to run a message loop for a thread. Threads by default do not have a message loop associated with them; to create one, call #prepare in the thread that is to run the loop, and then #loop to have it process messages until the loop is stopped.

Most interaction with a message loop is through the Handler class.

This is a typical example of the implementation of a Looper thread, using the separation of #prepare and #loop to create an initial Handler to communicate with the Looper.

class LooperThread extends Thread {
                 public Handler mHandler;

                 public void run() {
                     Looper.prepare();

                     mHandler = new Handler(Looper.myLooper()) {
                         public void handleMessage(Message msg) {
                             // process incoming messages here
                         }
                     };

                     Looper.loop();
                 }
             }

Java documentation for 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.

Constructors

Looper(IntPtr, JniHandleOwnership)

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

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsCurrentThread

Returns true if the current thread is this looper's thread.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
MainLooper

Returns the application's main looper, which lives in the main thread of the application.

PeerReference (Inherited from Object)
Queue

Gets this looper's message queue.

Thread

Gets the Thread associated with this Looper.

ThresholdClass

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

ThresholdType

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

Methods

Clone()

Creates and returns a copy of this object.

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

Dumps the state of the looper for debugging purposes.

Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Loop()

Run the message queue in this thread.

MyLooper()

Return the Looper object associated with the current thread.

MyQueue()

Return the MessageQueue object associated with the current thread.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Prepare()

Initialize the current thread as a looper.

PrepareMainLooper()

Initialize the current thread as a looper, marking it as an application's main looper.

Quit()

Quits the looper.

QuitSafely()

Quits the looper safely.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetMessageLogging(IPrinter)

Control logging of messages as they are processed by this Looper.

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

Returns a string representation of the object.

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

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

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

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to