gpt4 book ai didi

android - 隐藏自定义对话框时窗口泄漏

转载 作者:行者123 更新时间:2023-11-29 17:15:44 32 4
gpt4 key购买 nike

我正在使用以下代码创建自定义对话框。

private void alertLoginSuccess() {
customDialog.loadigText.setText("Login Successful...");
Glide.with(getApplicationContext())
.load(R.drawable.tick)
.into(customDialog.loadigIcon);
final Handler handler = new Handler();
final Runnable runnable = new Runnable() {
@Override
public void run() {
if (customDialog.isShowing()) {
customDialog.hide();
}
moveToDashboard(session_token);
}
};
handler.postDelayed(runnable, 1000);
}

当用户登录成功后,将出现登录成功对话框,然后他们将被移至仪表板。

但是我收到以下错误,

android.view.WindowLeaked: Activity com.know.LoginActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41ef86e0 G.E..... R.....I. 0,0-169,59} that was originally added here at android.view.ViewRootImpl.(ViewRootImpl.java:388) at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248) at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69) at android.app.Dialog.show(Dialog.java:286)

我怎样才能解决这个问题?

最佳答案

替换

customDialog.hide();

customDialog.dismiss();

因为在您移动到其他屏幕时 hide() 会导致泄漏窗口错误。

关于android - 隐藏自定义对话框时窗口泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39159021/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com