Android Looper和Handler分析(9)
来源:未知 责任编辑:责任编辑 发表时间:2014-04-20 03:36 点击:次
* at the beginning and ending of each message dispatch, identifying the
* target Handler and message contents.
*
* @param printer A Printer object that will receive log messages, or
* null to disable message logging.
*/
//设置调试输出对象,looper循环的时候会打印相关信息,用来调试用最好了。
public void setMessageLogging(Printer printer) {
mLogging = printer;
}
/**
* Return the {@link MessageQueue} object associated with the current
* thread. This must be called from a thread running a Looper, or a
* NullPointerException will be thrown.
*/
public static final MessageQueue myQueue() {
return myLooper().mQueue;
}
//创建一个新的looper对象,
//内部分配一个消息队列,设置mRun为true
private Looper() {
mQueue = new MessageQueue();
mRun = true;
mThread = Thread.currentThread();
}
public void quit() {
Message msg = Message.obtain();
// NOTE: By enqueueing directly into the message queue, the
// message is left with a null target. This is how we know it is
// a quit message.
mQueue.enqueueMessage(msg, 0);
}
/**
* Return the Thread associated with this Looper.
*/
public Thread getThread() {
return mThread;
}
//后面就简单了,打印,异常定义等。
public void dump(Printer pw, String prefix) {
pw.println(prefix + this);
pw.println(prefix + "mRun=" + mRun);
pw.println(prefix + "mThread=" + mThread);
pw.println(prefix + "mQueue=" + ((mQueue != null) ? mQueue : "(null"));
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>