开发者

onSaveInstanceState when click back button in Android

开发者 https://www.devze.com 2023-02-23 18:03 出处:网络
I 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 overrode the onSaveInstanceState method to save outState to be retr

I 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 overrode the onSaveInstanceState method to save outState to be retrieved in a second time but onSaveInstanceState is never called when the user clicks the back button.

Do you know why this hap开发者_开发技巧pens?


onSaveInstanceState() is not supposed to be called when the user presses BACK.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消