0
我通過其中包含的AsyncTask外部類的手段retreive從服務器數據:進度中的AsyncTask - onPostExecute方法後,顯示
public class GetTask extends AsyncTask<String, Void, JSONObject> {
private Context context;
ProgressDialog dialog;
public GetTask(Context cxt) {
context = cxt;
dialog = new ProgressDialog(context);
}
protected void onPreExecute() {
dialog.setTitle("Load...");
dialog.setMessage("Data...");
dialog.show();
super.onPreExecute();
}
@Override
protected JSONObject doInBackground(String... url) {
// code for retreive data
return jArray;
}
protected void onPostExecute(JSONObject object) {
dialog.dismiss();
super.onPostExecute(object);
}
}
我把這個任務從我的活動:檢索
Tasks task = new Tasks();
JSONObject json = task.new GetTask(this).execute(ServerURL).get();
我的數據成功但ProgressDialog顯示後super.onPostExecute(對象);方法,爲什麼?
P.S.對話框顯示後:
// Make sure the identity of this thread is that of the local process,
// and keep track of what that identity token actually is.
Binder.clearCallingIdentity();
final long ident = Binder.clearCallingIdentity();
內部Looper.class
對不起我的英語不好。 ))
你是否在你的任務? – Blackbelt 2013-04-29 11:59:26
你的意思是 - dialog.setCancelable(true); ? – xck 2013-04-29 12:02:22
不,我的意思是task.cancel(true)。你確定onPostExecute被調用嗎? – Blackbelt 2013-04-29 12:04:02