开发者

Android dev: screen orientation problems

开发者 https://www.devze.com 2023-01-13 21:02 出处:网络
ok i am having real troubles with screen orientation. My application has a countdown timer in it along with other variables.

ok i am having real troubles with screen orientation. My application has a countdown timer in it along with other variables. And everytime the screen goes from landscape to portrait mode all my variables get reset to their default value, and the countdown timer gets canceld and reset !!! Is the onCreate method called everytime the sc开发者_Python百科reen changes orintation ? is there a solution to this problem ?


Yes, onCreate is called every time you rotate the screen. You have to save state of your app by overriding onSaveInstanceState method and the restore the state at onCreate. At both methods you have Bundle object to store/retrieve state.

Read https://developer.android.com/guide/components/fundamentals.html#actlife for understanding activity life cycle.

0

精彩评论

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

关注公众号