I think the best place for this is onStop
protected void onStop() { super.onStop(); if (this.loaderTask != null) { this.loaderTask.cancel(false); } }
in my Task i, check as often as possible if the cancellation was triggered
protected String doInBackground(String... arg0) { if (this.isCancelled()) { return null; } }
and, of course, do not forget to delete data that can be returned, since there is no longer any action to get it
protected void onPostExecute(List<UserStatus> result) { if(!this.isCancelled()) {
source share