我想發送一個參數作爲參數,我想開始這個類,因爲這個asynctask想用來啓動不同的活動。從AsyncTask發送類作爲參數啓動intent
例子:
.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
new taskIntent().execute(**example1.class**);
}
}
.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
new taskIntent().execute(**example2.class**);
}
}
private class taskIntent extends AsyncTask<String, Integer, Void> {
ProgressDialog dialog;
@Override
protected Void doInBackground(String... params) {
return null;
}
@Override
protected void onPreExecute() {
dialog = ProgressDialog.show(Calendar.this, "",
"Loading...", true);
dialog.show();
}
protected void onPostExecute(Void unused){
Intent intent = new Intent(Calendar.this, **parameter[0]**);
startActivity(intent);
finish();
dialog.dismiss();
}
}
我怎麼能發送類作爲參數在意向使用它?
謝謝,我的英語不好
for one,Class!= String – njzk2
另外,考慮到你的doInBackground什麼都不做,我沒有看到AsyncTask的要點 – njzk2
我需要Asynctask使用進度對話框直到它加載其他類 – jlopez