Activity has leaked window that was originally added

后端 未结 30 3249
野趣味
野趣味 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:28

    The "Activity has leaked window that was originally added..." error occurs when you try show an alert after the Activity is effectively finished.

    You have two options AFAIK:

    1. Rethink the login of your alert: call dismiss() on the dialog before actually exiting your activity.
    2. Put the dialog in a different thread and run it on that thread (independent of the current activity).

提交回复
热议问题