android - AsyncTask in onDestroy() not being executed -


i want send logout information server, when app gets destroyed.

here's code:

@override protected void ondestroy() {     try {         log.i("myapp", "activity destroyed");         sharedpreferences prefs1 = getsharedpreferences("com.my.app", context.mode_private);         log.i("myapp", "step1");         string response;         log.i("myapp", "step2");         response = httpposter.logout(eventcodes.logout, logout_eventcode, prefs.getstring("sessionid", "null"));         log.i("myapp", "step3");         if (response.equals("logout")) {             log.i("myapp", "logged out succesfully");         } else {             log.i("myapp", "couldn't perform logout");         }         prefs1.edit().clear().commit();     }     catch (interruptedexception e) {         e.printstacktrace();     }      catch (executionexception e) {         e.printstacktrace();     }        super.ondestroy();   } 

but here's log, when close app home button's long click menu:

enter image description here

i can't debug here. place breakpoint, never gets fired while debugging.

is there reason, why asynctask doesn't called ondestroy()?

its not idea use asyntask in ondestroy() instead can have activity extends intentservice , give call activity ondestroy


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -