View android.widget.LinearLayout{...} has already been added to the window manager. 解决方法?

2022-08-23  435-3010/system_process I/NotificationService: cancelToast pkg=xxx.xxx.xxxx callback=android.app.ITransientNotification$Stub$Proxy@70eb841
2022-08-23  435-3010/system_process W/NotificationService: Toast already cancelled. pkg=xxx.xxx.xxxx callback=android.app.ITransientNotification$Stub$Proxy@70eb841
2022-08-23  1785-1785/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: xxx.xxx.xxxx, PID: 1785

    java.lang.IllegalStateException: View android.widget.LinearLayout{17f48c7 V.E...... ......ID 0,0-188,49} has already been added to the window manager.
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:328)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
        at android.widget.Toast$TN.handleShow(Toast.java:496)
        at android.widget.Toast$TN$1.handleMessage(Toast.java:400)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

 

 

看日志代码分析,toast的问题。

具体的解决方法,参考:

Android Toast 两个 Crash | Liu Tao

容易报 IllegalStateException: view has already been added to the window manager,Toast 也开始不听话了_jkwen2021的博客-CSDN博客 

猜你喜欢

转载自blog.csdn.net/weixin_42602900/article/details/126487864
今日推荐