Activity has leaked window that was originally added

后端 未结 30 3713
野趣味
野趣味 2020-11-21 05:48

What is this error, and why does it happen?

05-17 18:24:57.069: ERROR/WindowManager(18850): Activity com.mypkg.myP has leaked window com.android.internal.pol         


        
30条回答
  •  醉梦人生
    2020-11-21 06:12

    You're trying to show a Dialog after you've exited an Activity.

    [EDIT]

    This question is one of the top search on google for android developer, therefore Adding few important points from comments, which might be more helpful for future investigator without going in depth of comment conversation.

    Answer 1 :

    You're trying to show a Dialog after you've exited an Activity.

    Answer 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

    Answer 3

    Call dismiss() on the Dialog instance you created before exiting your Activity, e.g. in onPause() or onDestroy()

提交回复
热议问题