简体   繁体   中英

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.

Whenever android system destroy your activity because of low memory conditions onSaveInstance and then onRestoreInstance is called when it is recreated. Hence you should save the state in onSaveInstance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM