Blankj / AndroidUtilCode

:fire: Android developers should collect the following utils(updating).
https://blankj.com/2016/07/31/android-utils-code/
Apache License 2.0
33.32k stars 10.69k forks source link

在Activity中使用ToastUtils后finish当前activity,控制台会提示内存泄漏,用原生Toast.maketext就不会是咋回事呢? #1801

Open roybill opened 8 months ago

roybill commented 8 months ago

打印的泄漏日志: android.view.WindowLeaked: Activity com.bank.account.BuyActivity has leaked window android.widget.ImageView{b3912b1 V.ED..... ......ID 0,0-296,146} that was originally added here at android.view.ViewRootImpl.(ViewRootImpl.java:1038) at android.view.ViewRootImpl.(ViewRootImpl.java:1022) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:401) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:154) at com.blankj.utilcode.util.ToastUtils$WindowManagerToast.show(ToastUtils.java:630) at com.blankj.utilcode.util.ToastUtils$ActivityToast.showWithActivityWindow(ToastUtils.java:739) at com.blankj.utilcode.util.ToastUtils$ActivityToast.show(ToastUtils.java:680) at com.blankj.utilcode.util.ToastUtils$2.run(ToastUtils.java:494) at com.blankj.utilcode.util.ThreadUtils.runOnUiThread(ThreadUtils.java:70) at com.blankj.utilcode.util.UtilsBridge.runOnUiThread(UtilsBridge.java:554) at com.blankj.utilcode.util.ToastUtils.show(ToastUtils.java:483) at com.blankj.utilcode.util.ToastUtils.show(ToastUtils.java:472) at com.blankj.utilcode.util.ToastUtils.showShort(ToastUtils.java:412)

1041411123 commented 7 months ago

一样的问题,有内存泄漏

zhibo-tech commented 5 months ago

一样的问题,有内存泄漏问题

zhibo-tech commented 5 months ago

@Blankj

OneGreenHand-LXH commented 5 months ago

在页面销毁的时候调用ToastUtils.cancel(); 但是会取消吐司

jerry9433 commented 3 months ago

顶一个