¿Cómo mostrar progressDialog en Android?

i want to display progressDialog in my activity when im call webservices and call to webservices ends Dialog dismiss automatically can any know how to do this and i want some sample for it . Thankx in advance .

here is my code but it not working fine

final ProgressDialog dialog = ProgressDialog.show(
                RouteServicing.this, "", "Loading. Please wait...", true);

        final Handler handler = new Handler() {
            public void handleMessage(Message msg) {
                dialog.dismiss();
            }
        };

        Thread checkUpdate = new Thread() {
            public void run() {

                Status = cn.callWebService(url);
                getDetail(Status);
                //handler.sendEmptyMessage(0);
                dialog.dismiss();
            }
        };
        checkUpdate.start();

me muestra este error

    02-02 16:06:53.219: E/WindowManager(1127): android.view.WindowLeaked: Activity com.palewar.coinop.RouteServicing has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405db660 that was originally added here
02-02 16:06:53.219: E/WindowManager(1127):  at android.view.ViewRoot.<init>(ViewRoot.java:272)
02-02 16:06:53.219: E/WindowManager(1127):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
02-02 16:06:53.219: E/WindowManager(1127):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
02-02 16:06:53.219: E/WindowManager(1127):  at android.view.Window$LocalWindowManager.addView(Window.java:424)
02-02 16:06:53.219: E/WindowManager(1127):  at android.app.Dialog.show(Dialog.java:241)
02-02 16:06:53.219: E/WindowManager(1127):  at android.app.ProgressDialog.show(ProgressDialog.java:107)
02-02 16:06:53.219: E/WindowManager(1127):  at android.app.ProgressDialog.show(ProgressDialog.java:90)
02-02 16:06:53.219: E/WindowManager(1127):  at com.palewar.coinop.RouteServicing.onClick(RouteServicing.java:243)

preguntado el 02 de febrero de 12 a las 10:02

What isn't working? more information about specifics dont be so vague. -

3 Respuestas

Better try to use AsyncTask

Respondido 02 Feb 12, 14:02

change method to:

Thread checkUpdate = new Thread() {
            public void run() {

                Status = cn.callWebService(url);
                getDetail(Status);
                handler.sendEmptyMessage(0);
            }
        };

Respondido 02 Feb 12, 14:02

Can plz tell me what i need to change in the above method . - Sachin Gurnani

you haven't code properly. Just checkout how to do it properly aquí in my answer.

contestado el 23 de mayo de 17 a las 12:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.