I have progressDialog, which is used for my AsyncTask, while downloading file. In AsyncTask I have implemented theese methods:
@Override
protected void onCancelled() {
handleOnCancelled(this.result);
super.onCancelled();
}
@Override
protected void onCancelled(String result) {
super.onCancelled(result);
}
In my activty, I am declaring mProgressDialog and giving it onCancelListener:
mProgressDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
xml.cancel(true);
}
});
When I press back key, mProgressDialog is closed, onCancel (method above) is called, but Async Task still runs on the background. How to solve it?
Thanks