user1269301
user1269301

Reputation: 41

async task progress dialog show too late

progress dialog appear to, late probably after async task is finished,in doInBackground it calls a web service and parse an xml,the activity have to wait for some seconds if in xml is a bigger file

@Override
protected void onPreExecute(){
    super.onPreExecute();
    completed=false;
    this.progressDialog.show();

}

@Override
protected Boolean doInBackground(Integer... params) {
    t=HttpHelper.callWebService( url, soapAction,xml);
    if (t.equals("")){  
        return false;
    }
    else {
        try {
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            XMLReader xr = sp.getXMLReader();
            XMLHelperFile myXmlHelperFile = new XMLHelperFile();
            xr.setContentHandler(myXmlHelperFile);
            InputSource is = new InputSource(new StringReader(CallWebFile.t)); 
            xr.parse(is);
            mesaj = myXmlHelperFile.getParsedData(); 
            completed=true;
    } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }

}

@Override
protected void onPostExecute(Boolean result) {
    super.onPostExecute(result);
    if (completed==true && progressDialog.isShowing()) progressDialog.dismiss();
}


@Override
protected void onProgressUpdate(Integer... values) {
    super.onProgressUpdate(values);


    }
}

Upvotes: 3

Views: 567

Answers (2)

Robin Chander
Robin Chander

Reputation: 7415

You are missing a call to publishProgress as publishProgress(some int value); inside your doInBackground()

Upvotes: 0

arjoan
arjoan

Reputation: 1849

Just a guess. Initialize the progress dialog in preExecute()

Upvotes: 1

Related Questions