1

As you know like samsung, htc have a custom task manager menu like below. This menu can be popup up long press the home button. If my application is working in background and if i close it from Task Manager, i can not handle it. Activity onDestroy method is not invoked.

enter image description here

Winston
  • 1,800
  • 2
  • 20
  • 30

1 Answers1

3

Unfortunately there isn't a good answer for handling this situation. If the app is force-killed, onDestroy method isn't necessarily called. According to the documentation

Note: do not count on this method being called as a place for saving data! For example, if an activity is editing data in a content provider, those edits should be committed in either onPause() or onSaveInstanceState(Bundle), not here.

If you can, clean up in the onPause() method. In order for the user to get to that screen to kill the app, it has to have been backgrounded and thus onPause() would be called. (see documentation)

It looks like you're in a similar situation as the question being asked in another SO thread - https://stackoverflow.com/a/3856300/413254

Community
  • 1
  • 1
loeschg
  • 29,961
  • 26
  • 97
  • 150