PopupWindow之Activity com.avcit… has leaked

  今天遇到这样一个bug:

05-16 15:07:04.625: E/OpenGLRenderer(9495):   GL_INVALID_VALUE

05-16 15:07:15.647: E/WindowManager(9495): Activity cn.xs8.app.activity.news.Xs8_News_Corver has leaked window android.widget.PopupWindow$PopupViewContainer@4298c580 that was originally added here

05-16 15:07:15.647: E/WindowManager(9495): android.view.WindowLeaked: Activity cn.xs8.app.activity.news.Xs8_News_Corver has leaked window android.widget.PopupWindow$PopupViewContainer@4298c580 that was originally added here

05-16 15:07:15.647: E/WindowManager(9495): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:402)

05-16 15:07:15.647: E/WindowManager(9495): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:292)

05-16 15:07:15.647: E/WindowManager(9495): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)

05-16 15:07:15.647: E/WindowManager(9495): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)

05-16 15:07:15.647: E/WindowManager(9495): at android.view.Window$LocalWindowManager.addView(Window.java:547)

05-16 15:07:15.647: E/WindowManager(9495): at android.widget.PopupWindow.invokePopup(PopupWindow.java:988)

05-16 15:07:15.647: E/WindowManager(9495): at android.widget.PopupWindow.showAsDropDown(PopupWindow.java:897)

05-16 15:07:15.647: E/WindowManager(9495): at cn.xs8.app.activity.news.Xs8_News_BaseActivity.showPopupWindow(Xs8_News_BaseActivity.java:595)

05-16 15:07:15.647: E/WindowManager(9495): at cn.xs8.app.activity.news.Xs8_News_BaseActivity.onClick(Xs8_News_BaseActivity.java:277)

05-16 15:07:15.647: E/WindowManager(9495): at cn.xs8.app.activity.news.Xs8_News_Corver.onClick(Xs8_News_Corver.java:241)

05-16 15:07:15.647: E/WindowManager(9495): at android.view.View.performClick(View.java:4113)

05-16 15:07:15.647: E/WindowManager(9495): at android.view.View$PerformClick.run(View.java:17006)

05-16 15:07:15.647: E/WindowManager(9495): at android.os.Handler.handleCallback(Handler.java:615)

05-16 15:07:15.647: E/WindowManager(9495): at android.os.Handler.dispatchMessage(Handler.java:92)

05-16 15:07:15.647: E/WindowManager(9495): at android.os.Looper.loop(Looper.java:137)

05-16 15:07:15.647: E/WindowManager(9495): at android.app.ActivityThread.main(ActivityThread.java:4797)

05-16 15:07:15.647: E/WindowManager(9495): at java.lang.reflect.Method.invokeNative(Native Method)

05-16 15:07:15.647: E/WindowManager(9495): at java.lang.reflect.Method.invoke(Method.java:511)

05-16 15:07:15.647: E/WindowManager(9495): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)

05-16 15:07:15.647: E/WindowManager(9495): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)

05-16 15:07:15.647: E/WindowManager(9495): at dalvik.system.NativeStart.main(Native Method)

05-16 15:07:15.647: E/InputEventReceiver(9495): channel '44793748 PopupWindow:4363acf0 (client)' ~ Publisher closed input channel or an error occurred.  events=0x9

05-16 15:07:20.362: E/OpenGLRenderer(9495):   GL_INVALID_VALUE

这是因为这个popupWindow依赖的父Activity已经finish()的了,但是它还存在,所以回有上面的提示。 

如何进行修改呢?

如下所示,在onPause()中将它关闭掉,so easy!

public void onPause()

{

super.onPause();

if (popupWindow != null)

{

popupWindow.dismiss();

popupWindow = null;

}

}


你可能感兴趣的:(android,Activity,内存溢出,PopupWindow)