android - 运用WindowManager添加了一个Window,在销毁activity时总是报"has leaked window"
大家讲道理
大家讲道理 2017-04-17 17:33:47
0
1
442

代码大概如下

windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
windowManager.addView(linearLayout, layoutParams);
protected void onDestroy() {
    windowManager.removeView(linearLayout);
    super.onDestroy();
}

我在activity onDestory()时调用了windowManager的removeView()方法也不行,还是会报相同的错误。难道
说removeView()方法调用后创建的Window还会存在么?应该如何彻底删除这个Window。

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
Peter_Zhu

I answered it myself, just use the removeViewImmediate() method instead of the removeView() method

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template