当用户通过从所有打开的应用程序中滑动应用程序或按下后退按钮关闭应用程序时,我有一些资源可以清理(在服务器端)。在上述这些情况下,我的 onDestroy 没有被调用。所以我的问题是
Which callback method is needed for the above scenarios and Why?
最佳答案
最好将 onPause
方法放在 onDestroy
中 not 保证总是被调用,尤其是在你的 swipe-关闭案例。而且,onStop
也不保证在内存不足的情况下被调用。
Official document about onDestroy还说如下;
Note: do not count on this method being called as a place for saving data!
关于android - 强行关闭 Activity 但不会调用 onDestroy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34647372/