简体   繁体   English

android系统杀死应用程序时如何保存我的应用程序状态?

[英]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.

相关问题 android内部是否有方法知道系统何时终止我的应用程序? - Is there a method inside android to know when the system is going to kill my app? 如何保存我的Android应用程序的状态? - How to save the state of my android app? 当我的Android应用程序处于终止模式时,如何触发GA事件? - How to trigger GA events when my android app is in kill mode? 如何在我的 android 应用程序中保存夜间模式的状态? - How can I save the state of the night mode in my android app? 关闭后如何保存我的Android应用程序的状态? - How to save state of my android app after closing? Android:当系统重新启动我的App流程时,如何保存在Application类中初始化的对象 - Android: How to save objects initialised in the Application class when the System Restarts my App Process 使用Twilio SDK在Android中应用处于终止状态时,如何获取来电? - How to get incoming calls when app is in kill state in Android with Twilio SDK? Flutter 应用恢复; 当活动被系统杀死时如何保存应用程序状态? - Flutter app restoration; how to save the app state when the activity is killed by the system? 何时保存应用状态 - When to save the state of an app OnPause状态强制杀死Android应用程序 - OnPause state Force to Kill the Android App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM