0
對於此代碼段(我已排除doInBackground(), postExecute()
等) 如何在從CheckServer活動調用異步任務時傳遞Activity參數?從活動中調用AsyncTask
public class CheckServer extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
HttpTicket ticket= new HttpTicket(); //HOW IS THIS LINE DONE? WHAT PARAM SHOULD BE PASSED?
}
@SuppressWarnings("unused")
private class HttpTicket extends AsyncTask<String, String, String>
{
private Activity activity;
private ProgressDialog dialog;
public HttpTicket(Activity activity) {
this.activity = activity;
}
創建構造函數HttpTicket(Activity)。 HttpTicket ticket = new HttpTicket(Activity.this); ticket.execute(); – Amit 2013-04-05 08:36:22