问题描述
您好
我有一个在Android应用程序在运行时调用的活动:当用户单击后退按钮活动被破坏,我重写的onSaveInstanceState方法来保存outState在第二次检索但的onSaveInstanceState不会被调用,当用户点击后退按钮。
Helloi have an activity that is called at runtime in an Android App: when the user clicks the back button the Activity is destroyed and i override the onSaveInstanceState method to save outState to be retrieved in a second time but onSaveInstanceState is never called when the user click the back button.
你知道为什么会这样?
在此先感谢
推荐答案
的onSaveInstanceState()
是不应该被称为当用户presses BACK。
onSaveInstanceState()
is not supposed to be called when the user presses BACK.
它将被称为当用户更改配置(例如,旋转屏),Android是否认为活动是在同时仍然在栈上可到达,和其他也许少数情况下被破坏的危险。
It will be called when the user changes configuration (e.g., rotates the screen), if Android believes that the activity is at risk of being destroyed while still being reachable on the stack, and perhaps a few other cases.
这篇关于当的onSaveInstanceState Android中单击后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!