onDestroy() won't get called after this.finish()

时光毁灭记忆、已成空白 提交于 2019-12-01 21:43:49

If the user exits to the home screen this does not need to mean that the app should be exited. In most of the time it will give a better user experience if the app just goes to the background. Try to rely on saveInstanceState and onPause.

Exiting a app is seen as bad practice in the android world, featuring a phone with a good system for true multitouch can get better user experience if the app keeps running after pressing the home screen.

You are doing it wrong. This is what the Doc says:

Note: do not count on this method being called as a place for saving data! [...] 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.

http://developer.android.com/reference/android/app/Activity.html#onDestroy%28%29

Macarse

You should use onSaveInstanceState, check this link.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!