Question

i am writing here to ask you a litlle question about the progress dialog.

In fact, i call web service in my application, the progress dialog works very well.

But when i change the date of my object to do the call of my web service, the progress dialog appear, the results are receiveid. AND automatically, there is a new call of the web service and the progress dialog didn't dissmiss :-/

On my server JBoss, i can see the calls from my application. At the first create of my activity i have one call.

But at the second call, when i changed the date, there are two call. i don't know why because when i change one of my spinner its works fine, the web service is call and returns the results.

I call the web service in a asynctask. I do nothing with the progress dialog in the asynctask.

Here is the method where i call the progress dialog

public void callWebService()
{
    myProgressDialog = ProgressDialog.show(OverviewMoney.this,"", "Récupération liste des positions cash",true); 


       final Runnable runInUIThread = new Runnable() {
            public void run() {
             setListView();                
            }
          };

          new Thread() {
                @Override public void run() 
                {
                  loadListMoney();
                  myProgressDialog.dismiss();
                  uiThreadCallback.post(runInUIThread);                     
                  myProgressDialog= null;
                }
              }.start();
}

The method loadListMoney call my web service in a asynctask and the method setListView put my resultList in an adapter to print the list on a list view. Thanks in advance :-) (And sorry for my english)

Was it helpful?

Solution

Try this

public void callWebService()
{
    if (myProgressDialog != null) myProgressDialog.dismiss();
    myProgressDialog = ProgressDialog.show(OverviewMoney.this,"", "Récupération liste des positions cash",true); 


       final Runnable runInUIThread = new Runnable() {
            public void run() {
             setListView();                
            }
          };

          new Thread() {
                @Override public void run() 
                {
                  loadListMoney();
                  myProgressDialog.dismiss();
                  uiThreadCallback.post(runInUIThread);                     
                  myProgressDialog= null;
                }
              }.start();
}

According to my understanding, when this function is called twice 1st time it will start progress dialog and quickly another function call is placed so without dismissing previous progress dialog you were creating one more progress dialog. So that was the main cause of it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top