您的位置:首页 > 产品设计 > UI/UE

Looper.myLooper().quit() 报 NullPointerException

2015-11-10 22:44 537 查看
在调用 Looper.myLooper().quit() 的时候发现报 NullPointerException,通过 Android Studio 发现如下提示:



查阅了 Looper 的源码:

/**
* Return the Looper object associated with the current thread.  Returns
* null if the calling thread is not associated with a Looper.
*/
public static @Nullable Looper myLooper() {
return sThreadLocal.get();
}


原来我在另外的线程间接地调用了
Looper.myLooper().quit() 方法。通过 Handler 发送 QUIT 消息解决此问题。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: