秋梦无痕

一场秋雨无梦痕,春夜清风冻煞人。冬来冷水寒似铁,夏至京北蟑满城。

Avatar

Android: Activity has leaked window

from: stackoverflow

Android报错如下:
ERROR/WindowManager(18850): Activity com.ifyr.demo has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44c46ff0 that was originally added here
ERROR/WindowManager(18850): android.view.WindowLeaked: Activity com.ifyr.demo has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44c46ff0 that was originally added here

可能原因1:
You're trying to show a Dialog after you've exited an Activity.

可能原因2:
This error can be a little misleading in some circumstances (although the answer is still completely accurate) - i.e. in my case an unhandled Exception was thrown in an AsyncTask, which caused the Activity to shutdown, then an open progressdialog caused this Exception.. so the 'real' exception was a little earlier in the log

可能原因3:
Call dismiss() on the Dialog instance you created before exiting your Activity, e.g. in onPause() or onDestroy()