I'm trying to display a Dialog when any exception occurs in doInBackground
method of AsyncTask
. I know I can't display a dialog while previous task is running. So for this I tried to Cancel (finish) AsyncTask
like this,
try {
response= HttpService.doServerRequest(params);
} catch(Exception e){
task.cancel(true); //Cancelling AsyncTask
CustomException.onException(CurrentActivityName.this);
}
I have created a CustomException
class for handling all exceptions and for displaying a dialog that will tell some error has occurred. I know this type of question is already asked here but I am not getting any solution that's why I am asking.
Is there any way to finish all previous activity or finish AsyncTask
?
Please help.
Thanks in Advance.