Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我很好奇当工作线程尝试更改 UI 上的某些内容时,Android 如何处理这种情况。我的猜测是有一些消息队列(但与 UI 队列不同,由处理程序 + Looper 管理)并且系统在尝试发布消息时检查线程 ID。因此,我将不胜感激任何提示。
查看其中一个堆栈跟踪,似乎所有修改(使 a 无效View并使其需要重绘)a 的调用View最终都在android.view.ViewRootImpl类中,即:
View
android.view.ViewRootImpl
视图层次结构的顶部,实现 View 和 WindowManager 之间所需的协议。
在该类中,在允许更改视图之前,使用该getThread()方法检查线程标识。
getThread()