|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandroid.os.Looper
public class Looper
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() {
public void handleMessage(Message msg) {
// process incoming messages here
}
};
Looper.loop();
}
}
| Nested Class Summary | |
|---|---|
(package private) static class |
Looper.HandlerException
|
| Field Summary | |
|---|---|
(package private) MessageQueue |
mQueue
|
(package private) boolean |
mRun
|
(package private) Thread |
mThread
|
| Method Summary | |
|---|---|
void |
dump(Printer pw,
String prefix)
|
static Looper |
getMainLooper()
Returns the application's main looper, which lives in the main thread of the application. |
static void |
loop()
Run the message queue in this thread. |
static Looper |
myLooper()
Return the Looper object associated with the current thread. |
static MessageQueue |
myQueue()
Return the MessageQueue object associated with the current
thread. |
static void |
prepare()
Initialize the current thread as a looper. |
static void |
prepareMainLooper()
Initialize the current thread as a looper, marking it as an application's main looper. |
void |
quit()
|
void |
setMessageLogging(Printer printer)
Control logging of messages as they are processed by this Looper. |
String |
toString()
Returns a string containing a concise, human-readable description of the receiver. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
final MessageQueue mQueue
volatile boolean mRun
Thread mThread
| Method Detail |
|---|
public static final void prepare()
loop() after calling this method, and end it by calling
quit().
public static final void prepareMainLooper()
prepare()
public static final Looper getMainLooper()
public static final void loop()
quit() to end the loop.
public static final Looper myLooper()
public void setMessageLogging(Printer printer)
printer - A Printer object that will receive log messages, or
null to disable message logging.public static final MessageQueue myQueue()
MessageQueue object associated with the current
thread.
public void quit()
public void dump(Printer pw,
String prefix)
public String toString()
Object
toString in class Object
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||