I need to cancel my AsyncTask with a button in the progress dialog.
I've created the Progress dialog with the button. Here it is:
@Override
protected void onPreExecute() {
pDialog = new ProgressDialog(DSDactivity.this);
pDialog.setMessage(getResources().getString(R.string.pDialog));
pDialog.setCancelable(false);
pDialog.setButton("Cancel", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
pDialog.dismiss();
asyncCodelist.cancel(true);
}
});
pDialog.show();
}
I have two problems:
When I click "cancel" on the progress dialog is removed but the async task continues to do what he was doing
Eclipse gives me this waning:
The method setButton(CharSequence, DialogInterface.OnClickListener) from the type AlertDialog is deprecated