Take the Dialog for example.
Judge from the Android source code, let’s watch what happened when you called method Dialog#show() method. The code can be simplified as below:
public void show() {
if (mShowing) {
// ...
return;
}
// ...
mDecor = mWindow.getDecorView();
mWindowManager.addView(mDecor, l);
// ...
mShowing = true;
// ...
}
The mDecor field was got from mWidnow, the mWindow field was got from Dialog's construcor:
Dialog(@NonNull Context context, @

本文通过一个罕见的线上Crash案例,分析了由于在不同线程中两次显示Dialog导致的`java.lang.IllegalStateException`。详细探讨了Android中Window、DecorView和WindowManagerGlobal的关系,解释了为何重复添加相同View到WindowManagerGlobal会导致崩溃,并提供了问题的解决思路。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



