[英]How to save my app state when android system kill the app?
我知道按下主页按钮时会调用onPause,onStop和onSavedInstanceData,但是我怎么知道Android系统何时杀死我的应用程序或在任务管理器中销毁它?
Please note that when we press back button ie, ourself close the activity then onSaveInstance() is not called. 请注意,当我们按下后退按钮时,即我们自己关闭活动,则不会调用onSaveInstance()。
Whenever android system destroy your activity because of low memory conditions onSaveInstance and then onRestoreInstance is called when it is recreated. 每当android系统由于内存不足而破坏您的活动时,onSaveInstance会在重新创建时调用onRestoreInstance。 Hence you should save the state in onSaveInstance.
因此,您应该将状态保存在onSaveInstance中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.