我在按钮上使用AsyncTask单击刷新屏幕。以下为BTN发生的事件的顺序点击AsyncTask:使用网络服务和线程
- 进度对话框显示了
- 的doInBackground被称为和线程初始化它调用的Web服务。 Web服务提取/上传数据。一旦Web服务被调用,就会设置通过/失败标志。
我的问题是onPostExecute从不被调用,因此屏幕永远不会刷新。 其次,当数据下载并且Web服务设置标志时,我的代码已经在doInBackground中返回stmt。
问题是我如何停止执行我的asynctask,以便Web服务完成下载/上传数据并最终执行onPostexecute。
仅供参考 我也得到了以下警告从 日食
的方法onPostExecute(Boolean)将 型Screen.ConnectWebService是 从不在本地
private class ConnectWebService extends AsyncTask <Void, Void, Boolean>
{
private final ProgressDialog pd = new ProgressDialog(screen.this);
protected void onPreExecute() {
pd.show(Screen.this, "Sync", "Sync in progress",true,false);
}
protected Boolean doInBackground(Void... unused) {
if (SyncInProgress == false)
{
CallWSThread();//creates thread which calls web service
}
Log.d("doInBackground","doInBackground");
return SyncStatus;
}
protected Void onPostExecute(boolean result)
{
pd.dismiss();
if (result==true) drawRadioButtons();
return null;
}
}
只要删除你的方法,让eclipse自动生成它们。它将使用正确的输入参数,修饰符和重写符号创建它们。 – 2011-05-06 18:52:50