WindowManager:android.view.WindowLeaked

窗体泄露

来源:
按字面了解,Window Leaked大概就是说一个窗体泄漏了,也就是我们常说的内存泄漏,为什么窗体会泄漏呢?
解决办法:
关闭(finish)某个Activity前,要确保附属在上面的Dialog或PopupWindow已经关闭(dismiss)了。

错误日志 :

2019-06-05 15:45:07.008 7915-7915/com.cloudy.jun.test E/WindowManager: android.view.WindowLeaked: Activity com.xxx.xxxActivity has leaked window DecorView@c6050de[LoginActivity] that was originally added here
        at android.view.ViewRootImpl.(ViewRootImpl.java:622)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:391)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:129)
        at android.app.Dialog.show(Dialog.java:471)
        at android.app.AlertDialog$Builder.show(AlertDialog.java:1132)
        at com.cloudy.jun.module.login.LoginActivity.onResume(xxxActivity.java:322)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1456)
        at android.support.test.runner.MonitoringInstrumentation.callActivityOnResume(MonitoringInstrumentation.java:699)
        at android.app.Activity.performResume(Activity.java:7611)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4336)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4394)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2155)
        at android.os.Handler.dispatchMessage(Handler.java:109)
        at android.os.Looper.loop(Looper.java:207)
        at android.app.ActivityThread.main(ActivityThread.java:7539)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)

你可能感兴趣的:(android,android-面试)