我通過創建一個對象從函數中調用它。進度框出現然後消失,但不顯示吐司(我已經刪除了吐司後面的代碼,但是即使是代碼中的查詢該網頁不在doinBackground中執行)Android異步任務不起作用
private class MyTask extends AsyncTask<Void, Void, Void> {
MyTask(String p) {
enter=p;
}
protected void onPreExecute() {
progressDialog = ProgressDialog.show(CheckitoutActivity.this,"", "Loading. Please wait...", true);
}
protected Void doInBackground(Void... params) {
try {
Toast.makeText(getApplicationContext(), "GHJGFHGJL",1000).show();
}
}
@Override
protected void onPostExecute(Void result) {
progressDialog.dismiss();
}
}
doInBackground不應該被調用。即使是吐司也不會顯示,那爲什麼呢。
您是否開始該任務?日誌中是否有錯誤? – zapl 2012-03-17 12:23:27