进度对话框出现,可能在异步任务完成后,在doInBackground中调用Web服务并解析xml,如果在xml中是一个更大的文件,则活动必须等待几秒钟
@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);
}
}
答案 0 :(得分:1)
只是一个猜测。在preExecute()
中初始化进度对话框答案 1 :(得分:0)
您在doInBackground()
中缺少对publish {1}}的调用