Dominic Dominic - 2 months ago 26
Java Question

Android ProgessDialog weird console error message

I have a simple ProgessDialog. I show the dialog, call a method and later inside the method I hide the dialog but I am getting a console error.

ProgressDialog progressDialog = new ProgressDialog(ChangeEmailActivity.this);
progressDialog.setTitle("Loading");
progressDialog.show();


Inside the method

progressDialog.hide();



E/WindowManager: android.view.WindowLeaked: Activity de.at_c.liftkey.ChangeEmailActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{10f2f3a8 G.E..... R.....ID 0,0-729,322} that was originally added here
at android.view.ViewRootImpl.(ViewRootImpl.java:363)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:271)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:85)
at android.app.Dialog.show(Dialog.java:298)
at de.at_c.liftkey.ChangeEmailActivity$1.onClick(ChangeEmailActivity.java:42)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Answer

Use

progressDialog.dismiss();

Instead of

progressDialog.hide();

You need to dismiss the dialog instead of hiding it.