я думаю, что лучшее место для этого - onStop
protected void onStop() {
super.onStop();
/*
* The device may have been rotated and the activity is going to be destroyed
* you always should be prepared to cancel your AsnycTasks before the Activity
* which created them is going to be destroyed.
* And dont rely on mayInteruptIfRunning
*/
if (this.loaderTask != null) {
this.loaderTask.cancel(false);
}
}
в моей Задаче я затем проверяю как можно чаще, если отмена была вызвана
protected String doInBackground(String... arg0) {
if (this.isCancelled()) {
return null;
}
}
и, конечно же, не забудьте сбросить данные, которые могут быть возвращены, поскольку больше нет действий для их получения
protected void onPostExecute(List<UserStatus> result) {
if(!this.isCancelled()) {
//pass data to receiver
}
}