October 2018
Intermediate to advanced
464 pages
15h 17m
English
To cancel the task, call the cancel method on the object as follows:
< AsyncTask>.cancel(true);
You will need to have the object instance to access the cancel() method. (We did not save the object in our previous example.) After setting cancel(true), calling isCancelled() in doInBackground() will return true, allowing you to exit a loop. If cancelled, onCancelled() will be called instead of onPostExecute().