-1

I want to call method in ondestroy override method but that override method is not calling android o only. Why it is not calling is there any alternative for that please any one help me to resolve my issue.Thanks in advance.

v teja
  • 613
  • 2
  • 7
  • 17

2 Answers2

0

Given your comment that you are overriding onDestroy() in the activity and killing your app manually:

Please be aware that there it's not guaranteed that the onDestroy() will be called properly. Because of that, you should not perform critical actions there.

See an excerpt from 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. This method is usually implemented to free resources like threads that are associated with an activity, so that a destroyed activity does not leave such things around while the rest of its application is still running. There are situations where the system will simply kill the activity's hosting process without calling this method (or any others) in it, so it should not be used to do things that are intended to remain around after the process goes away.

W3hri
  • 1,563
  • 2
  • 18
  • 31
0

Need to work in android o, Could you send your codes?

  public void onDestroy() {
        ...
        // Must always call the super method at the end.
        super.onDestroy();
    }