window is leaked while hiding a custom dialog
Im using the following code to create a custom dialog.
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);
}
When the user has logged in successfully, the login successful dialog will appear and then they will be moved towards the dashboard.
But im getting the following error,
android.view.WindowLeaked: Activity com.know.LoginActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{41ef86e0 GE.... 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)
How can I be able to sort this out?
Replace
customDialog.hide();
with
customDialog.dismiss();
because hide() cause a leaked window error, while you are moving to other screen.
链接地址: http://www.djcxy.com/p/19942.html上一篇: 登录到WSO2 Agent后出错
下一篇: 隐藏自定义对话框时窗口被泄漏