2

I'm trying to call onCancelled() in AsyncTask. For cancelling a task I am invoking cancel(true). In my doInBackground, I have written this,

try {
        response= HttpService.doServerRequest(params);

    } catch(Exception e){
       //pd.dismiss();
         task.cancel(true);
         if(task.isCancelled()){
            CustomException.onException((Activity) this.context);
         }
   }

And I have override this method which will be called when task is cancelled.

@Override
protected void onCancelled() {
            CustomException.onException((Activity) this.context);
}

But this onCancelled() is not getting called after cancellation.

Please help.

Thanks.

Android
  • 183
  • 1
  • 13

0 Answers0