数据丢失时,旋转屏幕数据丢失、屏幕

2023-09-12 03:43:18 作者:被学习疯狂摧残

我在我的应用程序有点滑稽的错误。当用户旋转屏幕我失去了一些数据,在我的活动。任何有为什么出现这种情况的想法?

I have a little funny bug in my application. When the user rotates the screen I lose some of the data in my activity. Anyone that have an idea of why this happens?

在此先感谢 罗兰

推荐答案

在默认情况下,当屏幕旋转时的活动被杀害并重新启动。为了确保不丢失数据,您需要正确保存和使用的生命周期方法恢复数据。请参见保存持久状态。

By default, when the screen is rotated your Activity is killed and restarted. To make sure no data is lost, you need to properly save and restore your data using the lifecycle methods. See Saving Persistent State.