当我使用finish();
"The method finish() is undefined for the type SaveImageTask" 时,我的代码中出现此错误。我是否遗漏了一些声明或任何东西。有人可以指导我吗?
public class SaveImageTask extends AsyncTask<String , String , String> {
private Context context;
private ProgressDialog pDialog;
boolean bCancelled=false;
public SaveImageTask(Context context) {
this.context = context;
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
pDialog = new ProgressDialog(context);
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.setOnCancelListener(cancelListener);
pDialog.show();
}
@Override
protected String doInBackground(String... args) {
// TODO Auto-generated method stub
// MY STUFF
return null;
}
@Override
protected void onPostExecute(String args) {
// TODO Auto-generated method stub
pDialog.dismiss();
}
OnCancelListener cancelListener=new OnCancelListener(){
@Override
public void onCancel(DialogInterface arg0){
bCancelled=true;
SaveImageTask.this.finish(); // <<----"The method finish() is undefined for the type SaveImageTask"
}
};
}